protected override void ExecuteCore() { var normalizedTargetFrameworkVersion = ResolveFrameworkReferences.NormalizeVersion(new Version(TargetFrameworkVersion)); var knownAppHostPacksForTargetFramework = KnownAppHostPacks .Where(appHostPack => { var packTargetFramework = NuGetFramework.Parse(appHostPack.GetMetadata("TargetFramework")); return(packTargetFramework.Framework.Equals(TargetFrameworkIdentifier, StringComparison.OrdinalIgnoreCase) && ResolveFrameworkReferences.NormalizeVersion(packTargetFramework.Version) == normalizedTargetFrameworkVersion); }) .ToList(); if (knownAppHostPacksForTargetFramework.Count > 1) { throw new InvalidOperationException("Multiple KnownAppHostPack items applied to the specified target framework, which is not supposed to happen"); } if (knownAppHostPacksForTargetFramework.Count == 0) { return; } var packagesToDownload = new List <ITaskItem>(); if (!string.IsNullOrEmpty(AppHostRuntimeIdentifier)) { var appHostItem = GetAppHostItem(AppHostRuntimeIdentifier, knownAppHostPacksForTargetFramework, packagesToDownload); if (appHostItem != null) { AppHost = new ITaskItem[] { appHostItem }; } } if (PackAsToolShimRuntimeIdentifiers.Length > 0) { var packAsToolShimAppHostPacks = new List <ITaskItem>(); foreach (var runtimeIdentifier in PackAsToolShimRuntimeIdentifiers) { var appHostItem = GetAppHostItem(runtimeIdentifier.ItemSpec, knownAppHostPacksForTargetFramework, packagesToDownload); if (appHostItem != null) { packAsToolShimAppHostPacks.Add(appHostItem); } } PackAsToolShimAppHostPacks = packAsToolShimAppHostPacks.ToArray(); } if (packagesToDownload.Any()) { PackagesToDownload = packagesToDownload.ToArray(); } }
protected override void ExecuteCore() { var normalizedTargetFrameworkVersion = ResolveFrameworkReferences.NormalizeVersion(new Version(TargetFrameworkVersion)); var knownAppHostPacksForTargetFramework = KnownAppHostPacks .Where(appHostPack => { var packTargetFramework = NuGetFramework.Parse(appHostPack.GetMetadata("TargetFramework")); return(packTargetFramework.Framework.Equals(TargetFrameworkIdentifier, StringComparison.OrdinalIgnoreCase) && ResolveFrameworkReferences.NormalizeVersion(packTargetFramework.Version) == normalizedTargetFrameworkVersion); }) .ToList(); if (knownAppHostPacksForTargetFramework.Count > 1) { throw new InvalidOperationException("Multiple KnownAppHostPack items applied to the specified target framework, which is not supposed to happen"); } if (knownAppHostPacksForTargetFramework.Count == 0) { return; } var packagesToDownload = new List <ITaskItem>(); if (!string.IsNullOrEmpty(AppHostRuntimeIdentifier)) { var appHostItem = GetHostItem( AppHostRuntimeIdentifier, knownAppHostPacksForTargetFramework, packagesToDownload, DotNetAppHostExecutableNameWithoutExtension, "AppHost", isExecutable: true, errorIfNotFound: true); if (appHostItem != null) { AppHost = new ITaskItem[] { appHostItem }; } var comHostItem = GetHostItem( AppHostRuntimeIdentifier, knownAppHostPacksForTargetFramework, packagesToDownload, DotNetComHostLibraryNameWithoutExtension, "ComHost", isExecutable: false, errorIfNotFound: true); if (comHostItem != null) { ComHost = new ITaskItem[] { comHostItem }; } } if (PackAsToolShimRuntimeIdentifiers.Length > 0) { var packAsToolShimAppHostPacks = new List <ITaskItem>(); foreach (var runtimeIdentifier in PackAsToolShimRuntimeIdentifiers) { var appHostItem = GetHostItem( runtimeIdentifier.ItemSpec, knownAppHostPacksForTargetFramework, packagesToDownload, DotNetAppHostExecutableNameWithoutExtension, "AppHost", isExecutable: true, errorIfNotFound: true); if (appHostItem != null) { packAsToolShimAppHostPacks.Add(appHostItem); } } PackAsToolShimAppHostPacks = packAsToolShimAppHostPacks.ToArray(); } if (OtherRuntimeIdentifiers != null) { foreach (var otherRuntimeIdentifier in OtherRuntimeIdentifiers) { // Download any apphost packages for other runtime identifiers. // This allows you to specify the list of RIDs in RuntimeIdentifiers and only restore once, // and then build for each RuntimeIdentifier without restoring separately. // We discard the return value, and pass in some bogus data that won't be used, because // we won't use the assets from the apphost pack in this build. GetHostItem(otherRuntimeIdentifier, knownAppHostPacksForTargetFramework, packagesToDownload, hostNameWithoutExtension: "unused", itemName: "unused", isExecutable: true, errorIfNotFound: false); } } if (packagesToDownload.Any()) { PackagesToDownload = packagesToDownload.ToArray(); } }