Beispiel #1
0
   /// <summary>
   /// This method invokes <see cref="ExecuteMethodWithinNuGetAssemblyAsync"/> and saves the return value to file, if so configured.
   /// </summary>
   /// <param name="configuration">This <see cref="NuGetExecutionConfiguration"/></param>
   /// <param name="token">The <see cref="CancellationToken"/> to use when performing <c>async</c> operations.</param>
   /// <param name="restorer">The <see cref="BoundRestoreCommandUser"/> to use for restoring.</param>
   /// <param name="additionalParameterTypeProvider">The callback to provide values for method parameters with custom types.</param>
   /// <param name="appDomainSetup">The app domain setup for the assembly loader. The value <c>null</c> indicates that the loader should use current AppDomain.</param>
   /// <param name="getFiles">Optional <see cref="GetFileItemsDelegate"/> to use when creating <see cref="NuGetAssemblyResolver"/>.</param>
   /// <returns>The return value of the method, if the method returns integer synchronously or asynchronously.</returns>
   /// <exception cref="NullReferenceException">If this <see cref="NuGetExecutionConfiguration"/> is <c>null</c>.</exception>
   /// <exception cref="ArgumentNullException">If <paramref name="restorer"/> is <c>null</c>.</exception>
   /// <remarks>The <paramref name="additionalParameterTypeProvider"/> is only used when the method parameter type is not <see cref="CancellationToken"/>, or <see cref="Func{T, TResult}"/> delegate types which represent signatures of <see cref="NuGetAssemblyResolver"/> methods.</remarks>
#else
   /// <summary>
   /// This method invokes <see cref="ExecuteMethodWithinNuGetAssemblyAsync"/>, restoring the SDK package if so configured, and saves the return value to file, if so configured.
   /// </summary>
   /// <param name="configuration">This <see cref="NuGetExecutionConfiguration"/></param>
   /// <param name="token">The <see cref="CancellationToken"/> to use when performing <c>async</c> operations.</param>
   /// <param name="restorer">The <see cref="BoundRestoreCommandUser"/> to use for restoring.</param>
   /// <param name="additionalParameterTypeProvider">The callback to provide values for method parameters with custom types.</param>
   /// <param name="sdkPackageID">The package ID of the SDK package to restore, if so configured.</param>
   /// <param name="sdkPackageVersion">The package version of the SDK package to restore, if so configured.</param>
   /// <param name="getFiles">Optional <see cref="GetFileItemsDelegate"/> to use when creating <see cref="NuGetAssemblyResolver"/>.</param>
   /// <returns>The return value of the method, if the method returns integer synchronously or asynchronously.</returns>
   /// <exception cref="NullReferenceException">If this <see cref="NuGetExecutionConfiguration"/> is <c>null</c>.</exception>
   /// <exception cref="ArgumentNullException">If <paramref name="restorer"/> is <c>null</c>.</exception>
   /// <remarks>The <paramref name="additionalParameterTypeProvider"/> is only used when the method parameter type is not <see cref="CancellationToken"/>, or <see cref="Func{T, TResult}"/> delegate types which represent signatures of <see cref="NuGetAssemblyResolver"/> methods.</remarks>
#endif
   public static async Task<EitherOr<Object, NoExecutableMethodFound>> ExecuteMethodAndSerializeReturnValue(
      this NuGetExecutionConfiguration configuration,
      CancellationToken token,
      BoundRestoreCommandUser restorer,
      Func<Type, Object> additionalParameterTypeProvider,
#if NET46
      AppDomainSetup appDomainSetup
Beispiel #2
0
        protected override async Task <Int32> UseRestorerInParallelWithCancellationWatchingAsync(
            ConfigurationInformation <TConfiguration> info,
            CancellationToken token,
            BoundRestoreCommandUser restorer,
            String sdkPackageID,
            String sdkPackageVersion
            )
        {
            var config        = info.Configuration;
            var specialValues = new Dictionary <Type, Func <Object> >()
            {
                { typeof(Func <String>), () => config.ProjectFilePath }
            };

            var maybeResult = await config.ExecuteMethodAndSerializeReturnValue(
                token,
                restorer,
                type =>
            {
                return(specialValues.TryGetValue(type, out var factory) ?
                       factory() :
                       JsonConvert.DeserializeObject(config.InputProperties, type)
                       );
            },
#if NET46
                null
#else
                sdkPackageID,
                sdkPackageVersion
#endif
                , getFiles : restorer.ThisFramework.CreateMSBuildExecGetFilesDelegate()
                );

            return(maybeResult.IsFirst ? 0 : -4);
        }
Beispiel #3
0
        private static async Task WriteMethodInformationToFileAsync(
            CancellationToken token,
            BoundRestoreCommandUser restorer,
            String packageID,
            String packageVersion,
            String filePath,
            Assembly assembly
            )
        {
            // Should be fast, since the lock file should already been cached by previous restore call via loadnugetassembly call
            var packageNuGetVersion = (await restorer
                                       .RestoreIfNeeded(packageID, packageVersion, token))
                                      .Targets.Single()
                                      .Libraries
                                      .First(l => String.Equals(l.Name, packageID, StringComparison.CurrentCultureIgnoreCase))
                                      .Version;

            using (var writer = filePath.OpenStreamWriter())
            {
                await writer.WriteAsync(JsonConvert.SerializeObject(new PackageInspectionResult()
                {
                    ExactPackageVersion = new VersionRange(minVersion: packageNuGetVersion, includeMinVersion: true, maxVersion: packageNuGetVersion, includeMaxVersion: true).ToShortString(),
                    SuitableMethods     = assembly
                                          .GetTypes()
                                          .SelectMany(t => t.GetTypeInfo().FindSuitableMethodsForNuGetExec(null))
                                          .Select(method =>
                    {
                        var returnType = method.ReturnParameter.ParameterType.GetActualTypeForPropertiesScan();
                        return(new MethodInspectionResult()
                        {
                            MethodToken = method.MetadataToken,
                            MethodName = method.Name,
                            TypeName = method.DeclaringType.FullName,
                            InputParameters = method.GetParameters()
                                              .Select(p => p.ParameterType)
                                              .Where(t => t.IsEligibleInputOrOutputParameterType(true))
                                              .SelectMany(t => t.GetRuntimeProperties())
                                              .Distinct()
                                              .IncludeTaskProperties(false)
                                              .Select(p => p.CreatePropertyInfoObject())
                                              .ToArray(),
                            OutputParameters = typeof(void).Equals(returnType) || !returnType.IsEligibleInputOrOutputParameterType(false) ?
                                               Empty <ExecutableParameterInfo> .Array :
                                               returnType
                                               .GetRuntimeProperties()
                                               .IncludeTaskProperties(true)
                                               .Select(p => p.CreatePropertyInfoObject())
                                               .ToArray()
                        });
                    })
                                          .ToArray()
                }));
            }
        }
Beispiel #4
0
    private static String DeployByCopyingAssemblies(
        BoundRestoreCommandUser restorer,
        LockFile lockFile,
        String epAssemblyPath,
        JToken runtimeConfig,
        String sdkPackageID,
        String sdkPackageVersion,
        String targetPath
        )
    {
        var allAssemblyPaths = restorer.ExtractAssemblyPaths(
            lockFile,
            (packageID, assemblies) => assemblies
            ).Values
                               .SelectMany(v => v)
                               .Select(p => Path.GetFullPath(p))
                               .ToArray();

        // TODO flat copy will cause problems for assemblies with same simple name but different public key token
        // We need to put conflicting files into separate directories and generate appropriate runtime.config file (or .(dll|exe).config for desktop frameworks!)
        Parallel.ForEach(allAssemblyPaths, curPath => File.Copy(curPath, Path.Combine(targetPath, Path.GetFileName(curPath)), false));

        var targetAssemblyName = Path.Combine(targetPath, Path.GetFileName(epAssemblyPath));

        if (restorer.ThisFramework.IsDesktop())
        {
            // TODO .config file for conflicting file names
        }
        else
        {
            // We have to generate runtimeconfig.file (but disable probing path section creation)
            WriteRuntimeConfigFile(
                runtimeConfig,
                sdkPackageID,
                sdkPackageVersion,
                lockFile,
                false,
                targetAssemblyName
                );
        }

        return(targetAssemblyName);
    }
Beispiel #5
0
        protected override async Task <Int32> UseRestorerAsync(
            ConfigurationInformation <NuGetRestoreConfiguration> info,
            CancellationToken token,
            BoundRestoreCommandUser restorer,
            String sdkPackageID,
            String sdkPackageVersion
            )
        {
            if (!info.Configuration.SkipRestoringSDKPackage)
            {
                await restorer.RestoreIfNeeded(sdkPackageID, sdkPackageVersion, token);
            }

            var config          = info.Configuration;
            var packageID       = config.PackageID;
            var packageVersions = config.PackageVersions;
            await restorer.RestoreIfNeeded(
                token,
                String.IsNullOrEmpty( packageID )?
                config.PackageIDs.Select((pID, idx) => (pID, packageVersions.GetElementOrDefault(idx))).ToArray() :
                    new[] { (packageID, config.PackageVersion) }
Beispiel #6
0
        protected override async Task <Int32> UseRestorerAsync(
            ConfigurationInformation <NuGetExecutionConfigurationImpl> info,
            CancellationToken token,
            BoundRestoreCommandUser restorer,
            String sdkPackageID,
            String sdkPackageVersion
            )
        {
            var config      = info.Configuration;
            var maybeResult = await config.ExecuteMethodAndSerializeReturnValue(
                token,
                restorer,
                info.GetAdditonalTypeProvider(config.ProcessArguments),
                sdkPackageID,
                sdkPackageVersion
                );

            return(maybeResult.IsFirst ?
                   (maybeResult.First is Int32 actualInt ? actualInt : 0)
            : -3);
        }
Beispiel #7
0
        protected override async Task <Int32> UseRestorerInParallelWithCancellationWatchingAsync(
            ConfigurationInformation <TConfiguration> info,
            CancellationToken token,
            BoundRestoreCommandUser restorer,
            String sdkPackageID,
            String sdkPackageVersion
            )
        {
            var config = info.Configuration;

            await WriteEnvironmentInformationToFileAsync(
                config.DiscoverFilePath,
                new EnvironmentInspector(
                    config.PackageID,
                    config.PackageVersion,
                    config.PackageIDIsSelf,
                    config.ProjectFilePath
                    ).InspectEnvironment(restorer, sdkPackageID, sdkPackageVersion)
                );

            return(0);
        }
Beispiel #8
0
        protected override async Task <Int32> UseRestorerInParallelWithCancellationWatchingAsync(
            ConfigurationInformation <TConfiguration> info,
            CancellationToken token,
            BoundRestoreCommandUser restorer,
            String sdkPackageID,
            String sdkPackageVersion
            )
        {
            var config = info.Configuration;

            // Call WriteMethodInformationToFileAsync *inside* lambda, *before* the assembly loade is disposed.
            await config.FindMethodForExecutingWithinNuGetAssemblyAsync(
                token,
                restorer,
                async ( assemblyLoader, theAssembly, suitableMethod ) =>
            {
                await WriteMethodInformationToFileAsync(
                    token,
                    restorer,
                    config.PackageID,
                    config.PackageVersion,
                    config.InspectFilePath,
                    theAssembly
                    );

                return((Object)null);
            },
#if NET46
                null
#else
                sdkPackageID,
                sdkPackageVersion
#endif
                , getFiles : restorer.ThisFramework.CreateMSBuildExecGetFilesDelegate()
                );

            return(0);
        }
Beispiel #9
0
        protected override async Task <Int32> UseRestorerAsync(
            ConfigurationInformation <NuGetDeploymentConfigurationImpl> info,
            CancellationToken token,
            BoundRestoreCommandUser restorer,
            String sdkPackageID,
            String sdkPackageVersion
            )
        {
            (var epAssembly, var packageFramework) = await info.Configuration.DeployAsync(
                restorer,
                token,
                sdkPackageID,
                sdkPackageVersion
                );

            if (!String.IsNullOrEmpty(epAssembly) && packageFramework != null)
            {
                restorer.NuGetLogger.Log(NuGet.Common.LogLevel.Information, $"Deployed assembly to {epAssembly} (package framework is {packageFramework}).");
            }


            return(0);
        }
Beispiel #10
0
        public EnvironmentInspectionResult InspectEnvironment(
            BoundRestoreCommandUser restorer,
            String sdkPackageID,
            String sdkPackageVErsion
            )
        {
            const String SELF = "self";

            var packageID = this._packageID;

            global::NuGet.Packaging.Core.PackageIdentity selfPackageIdentity = null;
            var projectFile     = this._projectFileLocation;
            var packageIDIsSelf = this._packageIDIsSelf;
            var localRepos      = restorer.LocalRepositories;
            var errors          = new List <String>();

            if (String.IsNullOrEmpty(packageID))
            {
                if (packageIDIsSelf)
                {
                    // Package ID was specified as self
                    if (String.IsNullOrEmpty(projectFile))
                    {
                        errors.Add("NMSBT003");
                    }
                    else
                    {
                        projectFile = Path.GetFullPath(projectFile);
                        // The usage of this task factory comes from the package itself, deduce the package ID
                        selfPackageIdentity = SearchWithinNuGetRepository(
                            projectFile,
                            localRepos
                            .FirstOrDefault(kvp => projectFile.StartsWith(Path.GetFullPath(kvp.Key)))
                            .Value
                            ?.RepositoryRoot
                            );

                        if (selfPackageIdentity == null)
                        {
                            // Failed to deduce this package ID
                            // No PackageID element and no PackageIDIsSelf element either
                            errors.Add("NMSBT004");
                        }
                        else
                        {
                            packageID = selfPackageIdentity.Id;
                        }
                    }
                }
                else
                {
                    // No PackageID element and no PackageIDIsSelf element either
                    errors.Add("NMSBT002");
                }
            }
            else if (packageIDIsSelf)
            {
                packageID = null;
                errors.Add("NMSBT005");
            }

            String packageVersion = null;

            if (!String.IsNullOrEmpty(packageID))
            {
                packageVersion = this._packageVersion;
                if (
                    (String.IsNullOrEmpty(packageVersion) && packageIDIsSelf) ||
                    String.Equals(packageVersion, SELF, StringComparison.OrdinalIgnoreCase)
                    )
                {
                    // Instead of floating version, we need to deduce our version
                    NuGetVersion deducedVersion = null;
                    if (selfPackageIdentity == null)
                    {
                        // <PackageID> was specified normally, and <PackageVersion> was self
                        var localPackage = localRepos.Values
                                           .SelectMany(lr => lr.FindPackagesById(packageID))
                                           .Where(lp => projectFile.StartsWith(lp.ExpandedPath))
                                           .FirstOrDefault();
                        if (localPackage == null)
                        {
                            errors.Add("NMSBT006");
                        }
                        else
                        {
                            deducedVersion = localPackage.Version;
                        }
                    }
                    else
                    {
                        // <PackageIDIsSelf> was specified, and no version was specified
                        deducedVersion = selfPackageIdentity.Version;
                    }

                    packageVersion = deducedVersion?.ToNormalizedString();
                }
            }

            return(new EnvironmentInspectionResult()
            {
                ThisFramework = restorer.ThisFramework.ToString(),
                ThisRuntimeID = restorer.RuntimeIdentifier,
                SDKPackageID = sdkPackageID,
                SDKPackageVersion = sdkPackageVErsion,
                PackageID = packageID,
                PackageVersion = packageVersion,
                Errors = errors.ToArray()
            });
        }
Beispiel #11
0
    private static async Task <(LockFile, String, NuGetFramework)> RestoreAndFilterOutSDKPackages(
        this NuGetDeploymentConfiguration config,
        BoundRestoreCommandUser restorer,
        CancellationToken token,
        String restoreSDKPackageID,
        String restoreSDKPackageVersion
        )
    {
        var packageID = config.PackageID;
        var lockFile  = await restorer.RestoreIfNeeded(packageID, config.PackageVersion, token);

        // TODO better error messages
        var packagePath = restorer.ResolveFullPath(
            lockFile,
            lockFile.Libraries.FirstOrDefault(l => String.Equals(l.Name, packageID, StringComparison.OrdinalIgnoreCase))?.Path
            );
        var epAssemblyPath = NuGetUtility.GetAssemblyPathFromNuGetAssemblies(
            packageID,
            lockFile
            .Targets[0]
            .GetTargetLibrary(packageID)
            .RuntimeAssemblies
            .Select(ra => Path.GetFullPath(Path.Combine(packagePath, ra.Path)))
            .ToArray(),
            config.AssemblyPath
            );

        // We might be restoring .NETStandard package against .NETCoreApp framework, so find out the actual framework the package was built against.
        // So from path "/path/to/nuget/repo/package-id/package-version/lib/target-fw/package-id.dll" we want to extract the target-fw portion.
        // packagePath variable holds everything before the 'lib', so we just need to name of the folder 1 hierarchy level down from packagePath.
        var start            = GetNextSeparatorIndex(epAssemblyPath, packagePath.Length + 1) + 1;
        var end              = GetNextSeparatorIndex(epAssemblyPath, start);
        var packageFramework = NuGetFramework.ParseFolder(epAssemblyPath.Substring(start, end - start));

        //}
        //var targetFramework = restorer.ThisFramework;
        //sdkPackageID = NuGetUtility.GetSDKPackageID( targetFramework, config.ProcessSDKFrameworkPackageID ?? sdkPackageID );
        //sdkPackageVersion = NuGetUtility.GetSDKPackageVersion( targetFramework, sdkPackageID, config.ProcessSDKFrameworkPackageVersion ?? sdkPackageVersion );

        // Warning: The code below exploits the de facto behaviour that package named "System.XYZ" will contain assembly named "System.XYZ". Should sometime in the future this change, this code will then result in possibly wrong behaviour.
        // TODO I wonder if this assumption is needed anymore with .NET Standard and .NET Core 2+?

        var packageSDKPackageID = packageFramework.GetSDKPackageID(config.PackageSDKFrameworkPackageID);
        var sdkPackages         = new HashSet <String>(StringComparer.OrdinalIgnoreCase);

        if (!String.Equals(packageSDKPackageID, restoreSDKPackageID, StringComparison.OrdinalIgnoreCase))
        {
            // Typically when package is for .NET Standard and target framework is .NET Core
            var restoreLockFile = await restorer.RestoreIfNeeded(restoreSDKPackageID, restoreSDKPackageVersion, token);

            sdkPackages.UnionWith(restoreLockFile.Targets[0].GetAllDependencies(restoreSDKPackageID.Singleton())
                                  .SelectMany(lib => lib.Name.Singleton().Concat(lib.CompileTimeAssemblies.Select(cta => Path.GetFileNameWithoutExtension(cta.Path)).FilterUnderscores()))
                                  );
        }
        sdkPackages.UnionWith(lockFile.Targets[0].GetAllDependencies(packageSDKPackageID.Singleton()).Select(lib => lib.Name));


        var packageSDKPackageVersion = packageFramework.GetSDKPackageVersion(packageSDKPackageID, config.PackageSDKFrameworkPackageVersion);
        // In addition, check all compile assemblies from sdk package (e.g. Microsoft.NETCore.App )
        // Starting from 2.0.0, all assemblies from all dependent packages are marked as compile-assemblies stored in sdk package.
        var sdkPackageContainsAllPackagesAsAssemblies = config.PackageFrameworkIsPackageBased;

        Version.TryParse(packageSDKPackageVersion, out var sdkPkgVer);
        if (sdkPackageContainsAllPackagesAsAssemblies.IsTrue() ||
            (!sdkPackageContainsAllPackagesAsAssemblies.HasValue && packageFramework.IsPackageBased) // sdkPackageID == NuGetUtility.SDK_PACKAGE_NETCORE && sdkPkgVer != null && sdkPkgVer.Major >= 2 )
            )
        {
            var sdkPackageLibraries = lockFile.Targets[0].Libraries.Where(l => l.Name == packageSDKPackageID);

            if (sdkPkgVer != null)
            {
                sdkPackageLibraries = sdkPackageLibraries.Where(l => l.Version.Version >= sdkPkgVer);
            }

            var sdkPackageLibrary = sdkPackageLibraries.FirstOrDefault();

            if (sdkPackageLibrary == null && sdkPkgVer != null)
            {
                // We need to restore the correctly versioned SDK package
                sdkPackageLibrary = (await restorer.RestoreIfNeeded(packageSDKPackageID, packageSDKPackageVersion, token)).Targets[0].GetTargetLibrary(packageSDKPackageID);
            }

            if (sdkPackageLibrary != null)
            {
                sdkPackages.UnionWith(sdkPackageLibrary.CompileTimeAssemblies.Select(cta => Path.GetFileNameWithoutExtension(cta.Path)).FilterUnderscores());
            }
        }

        // Actually -> return LockFile, but modify it so that sdk packages are removed
        var targetLibs = lockFile.Targets[0].Libraries;

        for (var i = 0; i < targetLibs.Count;)
        {
            var curLib   = targetLibs[i];
            var contains = sdkPackages.Contains(curLib.Name);
            if (contains ||
                (
                    (curLib.RuntimeAssemblies.Count <= 0 || !curLib.RuntimeAssemblies.Select(ra => ra.Path).FilterUnderscores().Any()) &&
                    curLib.RuntimeTargets.Count <= 0 &&
                    curLib.ResourceAssemblies.Count <= 0 &&
                    curLib.NativeLibraries.Count <= 0
                )
                )
            {
                targetLibs.RemoveAt(i);
                if (!contains)
                {
                    sdkPackages.Add(curLib.Name);
                }
            }
            else
            {
                ++i;
            }
        }

        var libs = lockFile.Libraries;

        for (var i = 0; i < libs.Count;)
        {
            var curLib = libs[i];
            if (sdkPackages.Contains(curLib.Name))
            {
                libs.RemoveAt(i);
            }
            else
            {
                ++i;
            }
        }

        return(lockFile, epAssemblyPath, packageFramework);
    }
Beispiel #12
0
    /// <summary>
    /// Using information from this <see cref="NuGetDeploymentConfiguration"/>, restores the NuGet package, and deploys it by copying non-framework dependencies to target directory or by creating a <c>.deps.json</c> and <c>.runtimeconfig.json</c> files.
    /// </summary>
    /// <param name="config">This <see cref="NuGetDeploymentConfiguration"/>.</param>
    /// <param name="restorer">The <see cref="BoundRestoreCommandUser"/> to restore the NuGet package.</param>
    /// <param name="token">The <see cref="CancellationToken"/> to use when performing <c>async</c> operations.</param>
    /// <param name="sdkPackageID">The SDK package ID.</param>
    /// <param name="sdkPackageVersion">The SDK package version.</param>
    /// <returns>Asynchronously returns the full path to the deployed assembly, and a <see cref="NuGetFramework"/> which the assembly was built against.</returns>
    /// <exception cref="NullReferenceException">If this <see cref="NuGetDeploymentConfiguration"/> is <c>null</c>.</exception>
    /// <exception cref="ArgumentNullException">If <paramref name="restorer"/> is <c>null</c>.</exception>
    public static async Task <(String EntryPointAssemblyPath, NuGetFramework DeployedPackageFramework)> DeployAsync(
        this NuGetDeploymentConfiguration config,
        BoundRestoreCommandUser restorer,
        CancellationToken token,
        String sdkPackageID,
        String sdkPackageVersion
        )
    {
        ArgumentValidator.ValidateNotNullReference(config);
        ArgumentValidator.ValidateNotNull(nameof(restorer), restorer);

        (var lockFile, var entryPointAssembly, var packageFramework) = await config.RestoreAndFilterOutSDKPackages(
            restorer,
            token,
            sdkPackageID,
            sdkPackageVersion
            );


        JToken runtimeConfig     = null;
        var    runtimeConfigPath = Path.ChangeExtension(entryPointAssembly, RUNTIME_CONFIG_EXTENSION);

        if (File.Exists(runtimeConfigPath))
        {
            try
            {
                using (var streamReader = new StreamReader(File.OpenRead(runtimeConfigPath)))
                    using (var jsonReader = new JsonTextReader(streamReader))
                    {
                        runtimeConfig = JToken.ReadFrom(jsonReader);
                    }
            }
            catch
            {
                // Ignore
            }
        }

        var targetDirectory = CreateTargetDirectory(config.TargetDirectory);

        String assemblyToBeExecuted;

        switch (config.DeploymentKind)
        {
        case DeploymentKind.GenerateConfigFiles:
            if (restorer.ThisFramework.IsDesktop())
            {
                // This is not supported for desktop framework
                // TODO log warning
                assemblyToBeExecuted = DeployByCopyingAssemblies(
                    restorer,
                    lockFile,
                    entryPointAssembly,
                    runtimeConfig,
                    sdkPackageID,
                    sdkPackageVersion,
                    targetDirectory
                    );
            }
            else
            {
                assemblyToBeExecuted = DeployByGeneratingConfigFiles(
                    lockFile,
                    entryPointAssembly,
                    runtimeConfig,
                    sdkPackageID,
                    sdkPackageVersion,
                    targetDirectory
                    );
            }
            break;

        case DeploymentKind.CopyNonSDKAssemblies:
            assemblyToBeExecuted = DeployByCopyingAssemblies(
                restorer,
                lockFile,
                entryPointAssembly,
                runtimeConfig,
                sdkPackageID,
                sdkPackageVersion,
                targetDirectory
                );
            break;

        default:
            throw new NotSupportedException($"Unrecognized deployment kind: {config.DeploymentKind}.");
        }

        return(assemblyToBeExecuted, packageFramework);
    }