private bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) { if (excludedFrameworks == RuntimeFrameworks.None) { return true; } if (excludedFrameworks.HasFlag(RuntimeFrameworks.Mono) && TestPlatformHelper.IsMono) { return false; } if (excludedFrameworks.HasFlag(RuntimeFrameworks.CLR) && TestPlatformHelper.RuntimeEnvironment.RuntimeType.Equals("CLR", StringComparison.OrdinalIgnoreCase)) { return false; } if (excludedFrameworks.HasFlag(RuntimeFrameworks.CoreCLR) && TestPlatformHelper.RuntimeEnvironment.RuntimeType.Equals("CoreCLR", StringComparison.OrdinalIgnoreCase)) { return false; } return true; }
private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) { if (excludedFrameworks == RuntimeFrameworks.None) { return true; } #if NET451 if (excludedFrameworks.HasFlag(RuntimeFrameworks.Mono) && TestPlatformHelper.IsMono) { return false; } if (excludedFrameworks.HasFlag(RuntimeFrameworks.CLR)) { return false; } #else if (excludedFrameworks.HasFlag(RuntimeFrameworks.CoreCLR)) { return false; } #endif return true; }
private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) { if (excludedFrameworks == RuntimeFrameworks.None) { return(true); } #if NETFRAMEWORK if (excludedFrameworks.HasFlag(RuntimeFrameworks.Mono) && TestPlatformHelper.IsMono) { return(false); } if (excludedFrameworks.HasFlag(RuntimeFrameworks.CLR)) { return(false); } #elif NETSTANDARD2_0 || NET6_0_OR_GREATER if (excludedFrameworks.HasFlag(RuntimeFrameworks.CoreCLR)) { return(false); } #else #error Target frameworks need to be updated. #endif return(true); }
private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) { if (excludedFrameworks == RuntimeFrameworks.None) { return true; } #if NET461 || NET46 if (excludedFrameworks.HasFlag(RuntimeFrameworks.Mono) && TestPlatformHelper.IsMono) { return false; } if (excludedFrameworks.HasFlag(RuntimeFrameworks.CLR)) { return false; } #elif NETSTANDARD2_0 if (excludedFrameworks.HasFlag(RuntimeFrameworks.CoreCLR)) { return false; } #else #error Target frameworks need to be updated. #endif return true; }
private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) { if (excludedFrameworks == RuntimeFrameworks.None) { return(true); } if (excludedFrameworks.HasFlag(RuntimeFrameworks.Mono) && TestPlatformHelper.IsMono) { return(false); } if (excludedFrameworks.HasFlag(RuntimeFrameworks.CLR) && PlatformServices.Default.Runtime.RuntimeType.Equals("CLR", StringComparison.OrdinalIgnoreCase)) { return(false); } if (excludedFrameworks.HasFlag(RuntimeFrameworks.CoreCLR) && PlatformServices.Default.Runtime.RuntimeType.Equals("CoreCLR", StringComparison.OrdinalIgnoreCase)) { return(false); } return(true); }
private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) { if (excludedFrameworks == RuntimeFrameworks.None) { return(true); } if (excludedFrameworks.HasFlag(RuntimeFrameworks.Mono) && TestPlatformHelper.IsMono) { return(false); } if (excludedFrameworks.HasFlag(RuntimeFrameworks.CLR) && RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.OrdinalIgnoreCase)) { return(false); } if (excludedFrameworks.HasFlag(RuntimeFrameworks.CoreCLR) && RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.OrdinalIgnoreCase)) { return(false); } return(true); }
private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) { if (excludedFrameworks == RuntimeFrameworks.None) { return(true); } #if NET451 if (excludedFrameworks.HasFlag(RuntimeFrameworks.Mono) && TestPlatformHelper.IsMono) { return(false); } if (excludedFrameworks.HasFlag(RuntimeFrameworks.CLR)) { return(false); } #else if (excludedFrameworks.HasFlag(RuntimeFrameworks.CoreCLR)) { return(false); } #endif return(true); }
private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) { if (excludedFrameworks == RuntimeFrameworks.None) { return true; } if (excludedFrameworks.HasFlag(RuntimeFrameworks.Mono) && TestPlatformHelper.IsMono) { return false; } if (excludedFrameworks.HasFlag(RuntimeFrameworks.CLR) && RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.OrdinalIgnoreCase)) { return false; } if (excludedFrameworks.HasFlag(RuntimeFrameworks.CoreCLR) && RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.OrdinalIgnoreCase)) { return false; } return true; }
private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) { if (excludedFrameworks == RuntimeFrameworks.None) { return(true); } #if NET461 if (excludedFrameworks.HasFlag(RuntimeFrameworks.CLR)) { return(false); } #elif NETCOREAPP2_0 || NETCOREAPP2_1 if (excludedFrameworks.HasFlag(RuntimeFrameworks.CoreCLR)) { return(false); } #else #error target frameworks need to be updated. #endif return(true); }
private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) { if (excludedFrameworks == RuntimeFrameworks.None) { return(true); } #pragma warning disable IDE0046 // Convert to conditional expression #if NET461 if (excludedFrameworks.HasFlag(RuntimeFrameworks.CLR)) { return(false); } #elif NETCOREAPP2_0 || NETCOREAPP3_0 if (excludedFrameworks.HasFlag(RuntimeFrameworks.CoreCLR)) { return(false); } #else #error target frameworks need to be updated. #endif #pragma warning restore IDE0046 // Convert to conditional expression return(true); }
public FrameworkSkipConditionAttribute(RuntimeFrameworks excludedFrameworks) { _excludedFrameworks = excludedFrameworks; }
protected override void ExecuteCore() { List <TaskItem> referencesToAdd = new List <TaskItem>(); List <TaskItem> platformManifests = new List <TaskItem>(); PackageConflictPreferredPackages = string.Empty; List <TaskItem> packageConflictOverrides = new List <TaskItem>(); var resolvedTargetingPacks = ResolvedTargetingPacks.ToDictionary(item => item.ItemSpec, StringComparer.OrdinalIgnoreCase); foreach (var frameworkReference in FrameworkReferences) { ITaskItem targetingPack; resolvedTargetingPacks.TryGetValue(frameworkReference.ItemSpec, out targetingPack); string targetingPackRoot = targetingPack?.GetMetadata("Path"); if (string.IsNullOrEmpty(targetingPackRoot) || !Directory.Exists(targetingPackRoot)) { if (GenerateErrorForMissingTargetingPacks) { Log.LogError(Strings.UnknownFrameworkReference, frameworkReference.ItemSpec); } } else { string targetingPackFormat = targetingPack.GetMetadata("TargetingPackFormat"); if (targetingPackFormat.Equals("NETStandardLegacy", StringComparison.OrdinalIgnoreCase)) { AddNetStandardTargetingPackAssets(targetingPack, targetingPackRoot, referencesToAdd); } else { string targetingPackTargetFramework = targetingPack.GetMetadata("TargetFramework"); if (string.IsNullOrEmpty(targetingPackTargetFramework)) { targetingPackTargetFramework = "netcoreapp3.0"; } string targetingPackDataPath = Path.Combine(targetingPackRoot, "data"); string[] possibleDllFolders = new[] { Path.Combine(targetingPackRoot, "ref", targetingPackTargetFramework), targetingPackDataPath }; string[] possibleManifestPaths = new[] { Path.Combine(targetingPackRoot, "build", targetingPackTargetFramework, targetingPack.GetMetadata(MetadataKeys.PackageName) + ".PlatformManifest.txt"), Path.Combine(targetingPackDataPath, "PlatformManifest.txt"), Path.Combine(targetingPackDataPath, targetingPack.GetMetadata(MetadataKeys.PackageName) + ".PlatformManifest.txt"), }; string targetingPackDllFolder = possibleDllFolders.First(path => Directory.Exists(path) && Directory.GetFiles(path, "*.dll").Any()); string platformManifestPath = possibleManifestPaths.FirstOrDefault(File.Exists); string packageOverridesPath = Path.Combine(targetingPackDataPath, "PackageOverrides.txt"); string frameworkListPath = Path.Combine(targetingPackDataPath, "FrameworkList.xml"); if (File.Exists(frameworkListPath)) { AddReferencesFromFrameworkList(frameworkListPath, targetingPackDllFolder, targetingPack, referencesToAdd); } else { foreach (var dll in Directory.GetFiles(targetingPackDllFolder, "*.dll")) { var reference = CreateReferenceItem(dll, targetingPack); referencesToAdd.Add(reference); } } if (platformManifestPath != null) { platformManifests.Add(new TaskItem(platformManifestPath)); } if (File.Exists(packageOverridesPath)) { packageConflictOverrides.Add(CreatePackageOverride(targetingPack.GetMetadata("RuntimeFrameworkName"), packageOverridesPath)); } if (targetingPack.ItemSpec.Equals("Microsoft.NETCore.App", StringComparison.OrdinalIgnoreCase)) { // Hardcode this for now. Load this from the targeting pack once we have "real" targeting packs // https://github.com/dotnet/cli/issues/10581 PackageConflictPreferredPackages = "Microsoft.NETCore.App;runtime.linux-x64.Microsoft.NETCore.App;runtime.linux-x64.Microsoft.NETCore.App;runtime.linux-musl-x64.Microsoft.NETCore.App;runtime.linux-musl-x64.Microsoft.NETCore.App;runtime.rhel.6-x64.Microsoft.NETCore.App;runtime.rhel.6-x64.Microsoft.NETCore.App;runtime.osx-x64.Microsoft.NETCore.App;runtime.osx-x64.Microsoft.NETCore.App;runtime.freebsd-x64.Microsoft.NETCore.App;runtime.freebsd-x64.Microsoft.NETCore.App;runtime.win-x86.Microsoft.NETCore.App;runtime.win-x86.Microsoft.NETCore.App;runtime.win-arm.Microsoft.NETCore.App;runtime.win-arm.Microsoft.NETCore.App;runtime.win-arm64.Microsoft.NETCore.App;runtime.win-arm64.Microsoft.NETCore.App;runtime.linux-arm.Microsoft.NETCore.App;runtime.linux-arm.Microsoft.NETCore.App;runtime.linux-arm64.Microsoft.NETCore.App;runtime.linux-arm64.Microsoft.NETCore.App;runtime.tizen.4.0.0-armel.Microsoft.NETCore.App;runtime.tizen.4.0.0-armel.Microsoft.NETCore.App;runtime.tizen.5.0.0-armel.Microsoft.NETCore.App;runtime.tizen.5.0.0-armel.Microsoft.NETCore.App;runtime.win-x64.Microsoft.NETCore.App;runtime.win-x64.Microsoft.NETCore.App"; } } } } // Calculate which RuntimeFramework items should actually be used based on framework references HashSet <string> frameworkReferenceNames = new HashSet <string>(FrameworkReferences.Select(fr => fr.ItemSpec), StringComparer.OrdinalIgnoreCase); UsedRuntimeFrameworks = RuntimeFrameworks.Where(rf => frameworkReferenceNames.Contains(rf.GetMetadata(MetadataKeys.FrameworkName))) .ToArray(); // Filter out duplicate references (which can happen when referencing two different profiles that overlap) List <TaskItem> deduplicatedReferences = DeduplicateItems(referencesToAdd); ReferencesToAdd = deduplicatedReferences.Distinct().ToArray(); PlatformManifests = platformManifests.ToArray(); PackageConflictOverrides = packageConflictOverrides.ToArray(); }
protected override void ExecuteCore() { List <TaskItem> referencesToAdd = new List <TaskItem>(); List <TaskItem> platformManifests = new List <TaskItem>(); PackageConflictPreferredPackages = string.Empty; List <TaskItem> packageConflictOverrides = new List <TaskItem>(); var resolvedTargetingPacks = ResolvedTargetingPacks.ToDictionary(item => item.ItemSpec, StringComparer.OrdinalIgnoreCase); foreach (var frameworkReference in FrameworkReferences) { ITaskItem targetingPack; resolvedTargetingPacks.TryGetValue(frameworkReference.ItemSpec, out targetingPack); string targetingPackRoot = targetingPack?.GetMetadata("Path"); if (string.IsNullOrEmpty(targetingPackRoot) || !Directory.Exists(targetingPackRoot)) { if (GenerateErrorForMissingTargetingPacks) { Log.LogError(Strings.UnknownFrameworkReference, frameworkReference.ItemSpec); } } else { foreach (var dll in Directory.GetFiles(Path.Combine(targetingPackRoot, "ref", "netcoreapp3.0"), "*.dll")) { var reference = new TaskItem(dll); reference.SetMetadata(MetadataKeys.ExternallyResolved, "true"); reference.SetMetadata(MetadataKeys.Private, "false"); // TODO: Once we work out what metadata we should use here to display these references grouped under the targeting pack // in solution explorer, set that metadata here.These metadata values are based on what PCLs were using. // https://github.com/dotnet/sdk/issues/2802 reference.SetMetadata("WinMDFile", "false"); reference.SetMetadata("ReferenceGroupingDisplayName", targetingPack.ItemSpec); reference.SetMetadata("ReferenceGrouping", targetingPack.ItemSpec); reference.SetMetadata("ResolvedFrom", "TargetingPack"); reference.SetMetadata("IsSystemReference", "true"); referencesToAdd.Add(reference); } var platformManifestPath = Path.Combine(targetingPackRoot, "build", "netcoreapp3.0", targetingPack.GetMetadata(MetadataKeys.PackageName) + ".PlatformManifest.txt"); if (File.Exists(platformManifestPath)) { platformManifests.Add(new TaskItem(platformManifestPath)); } if (targetingPack.ItemSpec.Equals("Microsoft.NETCore.App", StringComparison.OrdinalIgnoreCase)) { // Hardcode this for now. Load this from the targeting pack once we have "real" targeting packs // https://github.com/dotnet/cli/issues/10581 PackageConflictPreferredPackages = "Microsoft.NETCore.App;runtime.linux-x64.Microsoft.NETCore.App;runtime.linux-x64.Microsoft.NETCore.App;runtime.linux-musl-x64.Microsoft.NETCore.App;runtime.linux-musl-x64.Microsoft.NETCore.App;runtime.rhel.6-x64.Microsoft.NETCore.App;runtime.rhel.6-x64.Microsoft.NETCore.App;runtime.osx-x64.Microsoft.NETCore.App;runtime.osx-x64.Microsoft.NETCore.App;runtime.freebsd-x64.Microsoft.NETCore.App;runtime.freebsd-x64.Microsoft.NETCore.App;runtime.win-x86.Microsoft.NETCore.App;runtime.win-x86.Microsoft.NETCore.App;runtime.win-arm.Microsoft.NETCore.App;runtime.win-arm.Microsoft.NETCore.App;runtime.win-arm64.Microsoft.NETCore.App;runtime.win-arm64.Microsoft.NETCore.App;runtime.linux-arm.Microsoft.NETCore.App;runtime.linux-arm.Microsoft.NETCore.App;runtime.linux-arm64.Microsoft.NETCore.App;runtime.linux-arm64.Microsoft.NETCore.App;runtime.tizen.4.0.0-armel.Microsoft.NETCore.App;runtime.tizen.4.0.0-armel.Microsoft.NETCore.App;runtime.tizen.5.0.0-armel.Microsoft.NETCore.App;runtime.tizen.5.0.0-armel.Microsoft.NETCore.App;runtime.win-x64.Microsoft.NETCore.App;runtime.win-x64.Microsoft.NETCore.App"; } } } HashSet <string> frameworkReferenceNames = new HashSet <string>(FrameworkReferences.Select(fr => fr.ItemSpec), StringComparer.OrdinalIgnoreCase); RuntimeFrameworksToRemove = RuntimeFrameworks.Where(rf => !frameworkReferenceNames.Contains(rf.GetMetadata(MetadataKeys.FrameworkName))) .ToArray(); ReferencesToAdd = referencesToAdd.ToArray(); PlatformManifests = platformManifests.ToArray(); PackageConflictOverrides = packageConflictOverrides.ToArray(); }
private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) { return(true); }
protected override void ExecuteCore() { bool writeDevRuntimeConfig = !string.IsNullOrEmpty(RuntimeConfigDevPath); if (!WriteAdditionalProbingPathsToMainConfig) { if (AdditionalProbingPaths?.Any() == true && !writeDevRuntimeConfig) { Log.LogWarning(Strings.SkippingAdditionalProbingPaths); } } if (!string.IsNullOrEmpty(RollForward)) { if (!RollForwardValues.Any(v => string.Equals(RollForward, v, StringComparison.OrdinalIgnoreCase))) { Log.LogError(Strings.InvalidRollForwardValue, RollForward, string.Join(", ", RollForwardValues)); return; } } if (AssetsFilePath == null) { var isFrameworkDependent = LockFileExtensions.IsFrameworkDependent( RuntimeFrameworks, IsSelfContained, RuntimeIdentifier, string.IsNullOrWhiteSpace(PlatformLibraryName)); if (isFrameworkDependent != true) { throw new ArgumentException( $"{nameof(DependencyContextBuilder)} Does not support non FrameworkDependent without asset file. " + $"runtimeFrameworks: {string.Join(",", RuntimeFrameworks.Select(r => r.ItemSpec))} " + $"isSelfContained: {IsSelfContained} " + $"runtimeIdentifier: {RuntimeIdentifier} " + $"platformLibraryName: {PlatformLibraryName}"); } if (PlatformLibraryName != null) { throw new ArgumentException( "Does not support non null PlatformLibraryName(TFM < 3) without asset file."); } WriteRuntimeConfig( RuntimeFrameworks.Select(r => new ProjectContext.RuntimeFramework(r)).ToArray(), null, isFrameworkDependent: true, new List <LockFileItem>()); } else { LockFile lockFile = new LockFileCache(this).GetLockFile(AssetsFilePath); ProjectContext projectContext = lockFile.CreateProjectContext( NuGetUtils.ParseFrameworkName(TargetFrameworkMoniker), RuntimeIdentifier, PlatformLibraryName, RuntimeFrameworks, IsSelfContained); WriteRuntimeConfig(projectContext.RuntimeFrameworks, projectContext.PlatformLibrary, projectContext.IsFrameworkDependent, projectContext.LockFile.PackageFolders); if (writeDevRuntimeConfig) { WriteDevRuntimeConfig(projectContext.LockFile.PackageFolders); } } }
protected override void ExecuteCore() { List <TaskItem> referencesToAdd = new List <TaskItem>(); List <TaskItem> platformManifests = new List <TaskItem>(); PackageConflictPreferredPackages = string.Empty; List <TaskItem> packageConflictOverrides = new List <TaskItem>(); List <string> preferredPackages = new List <string>(); var resolvedTargetingPacks = ResolvedTargetingPacks.ToDictionary(item => item.ItemSpec, StringComparer.OrdinalIgnoreCase); foreach (var frameworkReference in FrameworkReferences) { ITaskItem targetingPack; resolvedTargetingPacks.TryGetValue(frameworkReference.ItemSpec, out targetingPack); string targetingPackRoot = targetingPack?.GetMetadata(MetadataKeys.Path); if (string.IsNullOrEmpty(targetingPackRoot) || !Directory.Exists(targetingPackRoot)) { if (GenerateErrorForMissingTargetingPacks) { Log.LogError(Strings.UnknownFrameworkReference, frameworkReference.ItemSpec); } } else { string targetingPackFormat = targetingPack.GetMetadata("TargetingPackFormat"); if (targetingPackFormat.Equals("NETStandardLegacy", StringComparison.OrdinalIgnoreCase)) { AddNetStandardTargetingPackAssets(targetingPack, targetingPackRoot, referencesToAdd); } else { string targetingPackTargetFramework = targetingPack.GetMetadata("TargetFramework"); if (string.IsNullOrEmpty(targetingPackTargetFramework)) { targetingPackTargetFramework = "netcoreapp3.0"; } string targetingPackDataPath = Path.Combine(targetingPackRoot, "data"); string targetingPackDllFolder = Path.Combine(targetingPackRoot, "ref", targetingPackTargetFramework); // Fall back to netcoreapp5.0 folder if looking for net5.0 and it's not found if (!Directory.Exists(targetingPackDllFolder) && targetingPackTargetFramework.Equals("net5.0", StringComparison.OrdinalIgnoreCase)) { targetingPackTargetFramework = "netcoreapp5.0"; targetingPackDllFolder = Path.Combine(targetingPackRoot, "ref", targetingPackTargetFramework); } string platformManifestPath = Path.Combine(targetingPackDataPath, "PlatformManifest.txt"); string packageOverridesPath = Path.Combine(targetingPackDataPath, "PackageOverrides.txt"); string frameworkListPath = Path.Combine(targetingPackDataPath, "FrameworkList.xml"); AddReferencesFromFrameworkList(frameworkListPath, targetingPackDllFolder, targetingPack, referencesToAdd); if (File.Exists(platformManifestPath)) { platformManifests.Add(new TaskItem(platformManifestPath)); } if (File.Exists(packageOverridesPath)) { packageConflictOverrides.Add(CreatePackageOverride(targetingPack.GetMetadata(MetadataKeys.NuGetPackageId), packageOverridesPath)); } preferredPackages.AddRange(targetingPack.GetMetadata(MetadataKeys.PackageConflictPreferredPackages).Split(';')); } } } // Calculate which RuntimeFramework items should actually be used based on framework references HashSet <string> frameworkReferenceNames = new HashSet <string>(FrameworkReferences.Select(fr => fr.ItemSpec), StringComparer.OrdinalIgnoreCase); UsedRuntimeFrameworks = RuntimeFrameworks.Where(rf => frameworkReferenceNames.Contains(rf.GetMetadata(MetadataKeys.FrameworkName))) .ToArray(); // Filter out duplicate references (which can happen when referencing two different profiles that overlap) List <TaskItem> deduplicatedReferences = DeduplicateItems(referencesToAdd); ReferencesToAdd = deduplicatedReferences.Distinct().ToArray(); PlatformManifests = platformManifests.ToArray(); PackageConflictOverrides = packageConflictOverrides.ToArray(); PackageConflictPreferredPackages = string.Join(";", preferredPackages); }