Пример #1
0
        protected override void ExecuteCore()
        {
            NuGetFramework targetFramework = NuGetUtils.ParseFrameworkName(TargetFrameworkMoniker);
            LockFile       lockFile        = new LockFileCache(this).GetLockFile(ProjectAssetsFile);

            _packageResolver = NuGetPackageResolver.CreateResolver(lockFile, ProjectPath);

            var embeddedApphostPaths = new List <ITaskItem>();

            foreach (var runtimeIdentifier in ShimRuntimeIdentifiers.Select(r => r.ItemSpec))
            {
                var resolvedApphostAssetPath = GetApphostAsset(targetFramework, lockFile, runtimeIdentifier);

                var packagedShimOutputDirectoryAndRid = Path.Combine(
                    PackagedShimOutputDirectory,
                    runtimeIdentifier);

                var appHostDestinationFilePath = Path.Combine(
                    packagedShimOutputDirectoryAndRid,
                    ToolCommandName + Path.GetExtension(resolvedApphostAssetPath));

                Directory.CreateDirectory(packagedShimOutputDirectoryAndRid);

                // This is the embedded string. We should normalize it on forward slash, so the file won't be different according to
                // build machine.
                var appBinaryFilePath = string.Join("/",
                                                    new[] {
                    ".store",
                    PackageId.ToLowerInvariant(),
                    PackageVersion,
                    PackageId.ToLowerInvariant(),
                    PackageVersion,
                    "tools",
                    targetFramework.GetShortFolderName(),
                    "any",
                    ToolEntryPoint
                });

                AppHost.Create(
                    resolvedApphostAssetPath,
                    appHostDestinationFilePath,
                    appBinaryFilePath,
                    overwriteExisting: true
                    );

                var item = new TaskItem(appHostDestinationFilePath);
                item.SetMetadata("ShimRuntimeIdentifier", runtimeIdentifier);
                embeddedApphostPaths.Add(item);
            }

            EmbeddedApphostPaths = embeddedApphostPaths.ToArray();
        }
Пример #2
0
        protected override void ExecuteCore()
        {
            var embeddedApphostPaths = new List <ITaskItem>();

            foreach (var runtimeIdentifier in ShimRuntimeIdentifiers.Select(r => r.ItemSpec))
            {
                var resolvedApphostAssetPath = GetApphostAsset(ApphostsForShimRuntimeIdentifiers, runtimeIdentifier);

                var packagedShimOutputDirectoryAndRid = Path.Combine(
                    PackagedShimOutputDirectory,
                    runtimeIdentifier);

                var appHostDestinationFilePath = Path.Combine(
                    packagedShimOutputDirectoryAndRid,
                    ToolCommandName + ExecutableExtension.ForRuntimeIdentifier(runtimeIdentifier));

                Directory.CreateDirectory(packagedShimOutputDirectoryAndRid);

                // per https://github.com/dotnet/cli/issues/9870 nuget layout (as in {packageid}/{packageversion}/tools/)is normalized version
                var normalizedPackageVersion = NuGetVersion.Parse(PackageVersion).ToNormalizedString();
                // This is the embedded string. We should normalize it on forward slash, so the file won't be different according to
                // build machine.
                var appBinaryFilePath = string.Join("/",
                                                    new[] {
                    ".store",
                    PackageId.ToLowerInvariant(),
                    normalizedPackageVersion,
                    PackageId.ToLowerInvariant(),
                    normalizedPackageVersion,
                    "tools",
                    NuGetUtils.ParseFrameworkName(TargetFrameworkMoniker).GetShortFolderName(),
                    "any",
                    ToolEntryPoint
                });

                AppHost.Create(
                    resolvedApphostAssetPath,
                    appHostDestinationFilePath,
                    appBinaryFilePath
                    );

                var item = new TaskItem(appHostDestinationFilePath);
                item.SetMetadata(MetadataKeys.ShimRuntimeIdentifier, runtimeIdentifier);
                embeddedApphostPaths.Add(item);
            }

            EmbeddedApphostPaths = embeddedApphostPaths.ToArray();
        }
Пример #3
0
        protected override void ExecuteCore()
        {
            var embeddedApphostPaths = new List <ITaskItem>();

            foreach (var runtimeIdentifier in ShimRuntimeIdentifiers.Select(r => r.ItemSpec))
            {
                var packagedShimOutputDirectoryAndRid = Path.Combine(
                    PackagedShimOutputDirectory,
                    runtimeIdentifier);

                var appHostDestinationFilePath = Path.Combine(
                    packagedShimOutputDirectoryAndRid,
                    ToolCommandName + ExecutableExtension.ForRuntimeIdentifier(runtimeIdentifier));

                var item = new TaskItem(appHostDestinationFilePath);
                item.SetMetadata(MetadataKeys.ShimRuntimeIdentifier, runtimeIdentifier);
                embeddedApphostPaths.Add(item);
            }

            EmbeddedApphostPaths = embeddedApphostPaths.ToArray();
        }
Пример #4
0
        protected override void ExecuteCore()
        {
            var embeddedApphostPaths = new List <ITaskItem>();

            foreach (var runtimeIdentifier in ShimRuntimeIdentifiers.Select(r => r.ItemSpec))
            {
                var resolvedApphostAssetPath = GetApphostAsset(ApphostsForShimRuntimeIdentifiers, runtimeIdentifier);

                var packagedShimOutputDirectoryAndRid = Path.Combine(
                    PackagedShimOutputDirectory,
                    runtimeIdentifier);

                var appHostDestinationFilePath = Path.Combine(
                    packagedShimOutputDirectoryAndRid,
                    ToolCommandName + ExecutableExtension.ForRuntimeIdentifier(runtimeIdentifier));

                Directory.CreateDirectory(packagedShimOutputDirectoryAndRid);

                // per https://github.com/dotnet/cli/issues/9870 nuget layout (as in {packageid}/{packageversion}/tools/)is normalized version
                var normalizedPackageVersion = NuGetVersion.Parse(PackageVersion).ToNormalizedString();
                // This is the embedded string. We should normalize it on forward slash, so the file won't be different according to
                // build machine.
                var appBinaryFilePath = string.Join("/",
                                                    new[] {
                    ".store",
                    PackageId.ToLowerInvariant(),
                    normalizedPackageVersion,
                    PackageId.ToLowerInvariant(),
                    normalizedPackageVersion,
                    "tools",
                    NuGetUtils.ParseFrameworkName(TargetFrameworkMoniker).GetShortFolderName(),
                    "any",
                    ToolEntryPoint
                });

                try
                {
                    var windowsGraphicalUserInterface = runtimeIdentifier.StartsWith("win") && "WinExe".Equals(OutputType, StringComparison.OrdinalIgnoreCase);
                    if (ResourceUpdater.IsSupportedOS() && runtimeIdentifier.StartsWith("win"))
                    {
                        HostWriter.CreateAppHost(appHostSourceFilePath: resolvedApphostAssetPath,
                                                 appHostDestinationFilePath: appHostDestinationFilePath,
                                                 appBinaryFilePath: appBinaryFilePath,
                                                 windowsGraphicalUserInterface: windowsGraphicalUserInterface,
                                                 assemblyToCopyResorcesFrom: IntermediateAssembly);
                    }
                    else
                    {
                        // by passing null to assemblyToCopyResorcesFrom, it will skip copying resources,
                        // which is only supported on Windows
                        if (windowsGraphicalUserInterface)
                        {
                            Log.LogWarning(Strings.AppHostCustomizationRequiresWindowsHostWarning);
                        }

                        HostWriter.CreateAppHost(appHostSourceFilePath: resolvedApphostAssetPath,
                                                 appHostDestinationFilePath: appHostDestinationFilePath,
                                                 appBinaryFilePath: appBinaryFilePath,
                                                 windowsGraphicalUserInterface: false,
                                                 assemblyToCopyResorcesFrom: null);
                    }
                }
                catch (AppNameTooLongException ex)
                {
                    throw new BuildErrorException(Strings.FileNameIsTooLong, ex.LongName);
                }
                catch (PlaceHolderNotFoundInAppHostException ex)
                {
                    throw new BuildErrorException(Strings.AppHostHasBeenModified, resolvedApphostAssetPath, BitConverter.ToString(ex.MissingPattern));
                }

                var item = new TaskItem(appHostDestinationFilePath);
                item.SetMetadata(MetadataKeys.ShimRuntimeIdentifier, runtimeIdentifier);
                embeddedApphostPaths.Add(item);
            }

            EmbeddedApphostPaths = embeddedApphostPaths.ToArray();
        }