public SdkProjectMetaData(string fullProjectPath, TargetFrameworkMoniker priorityFxVersion = TargetFrameworkMoniker.net452) { if (!string.IsNullOrEmpty(fullProjectPath)) { MsBuildProject = GetProject(fullProjectPath); if (MsBuildProject != null) { FxMoniker = GetTargetFramework(MsBuildProject, priorityFxVersion); FxMonikerString = GetFxMonikerString(priorityFxVersion); ProjectTaskItem = new Microsoft.Build.Utilities.TaskItem(fullProjectPath); FullProjectPath = fullProjectPath; TargetOutputFullPath = GetTargetFullPath(MsBuildProject, FxMonikerString); ProjectType = GetProjectType(MsBuildProject); IsTargetFxSupported = IsFxSupported(FxMonikerString); IsProjectDataPlane = IsDataPlaneProject(MsBuildProject); IsFxFullDesktopVersion = IsExpectedFxCategory(FxMoniker, TargetFxCategory.FullDesktop); IsFxNetCore = IsExpectedFxCategory(FxMoniker, TargetFxCategory.NetCore); ProjectImports = GetProjectImports(MsBuildProject); } else { throw new NullReferenceException("MsBuild Project null"); } } }
public TargetFrameworkExecutionTarget(TargetFrameworkMoniker framework) { Id = framework.ShortName; Name = framework.ShortName; Framework = framework; Image = "md-framework-dependency"; }
public string GenerateDatabase(string runtimeId, TargetFrameworkMoniker fxId, string baseDir, string assemblyFile) { try { Runtime.Initialize(false); ParserDatabase pdb = new ParserDatabase(); TargetRuntime runtime = Runtime.SystemAssemblyService.GetTargetRuntime(runtimeId); if (runtime == null) { LoggingService.LogError("Runtime '{0}' not found", runtimeId); } TargetFramework fx = Runtime.SystemAssemblyService.GetTargetFramework(fxId); // Generate the new db in a temp file. The main process will move the file if required. using (var db = new AssemblyCodeCompletionDatabase(runtime, fx, assemblyFile, pdb, true)) { if (db.LoadError) { throw new InvalidOperationException("Could find assembly: " + assemblyFile); } db.ParseInExternalProcess = false; db.ParseAll(); db.Write(); return(db.RealDataFile); } } catch (Exception ex) { Console.WriteLine(ex); return(null); } }
public SdkProjectMetaData(string fullProjectPath, TargetFrameworkMoniker priorityFxVersion = TargetFrameworkMoniker.net452) { if (!string.IsNullOrEmpty(fullProjectPath)) { try { if (ProjectCollection.GlobalProjectCollection.GetLoadedProjects(fullProjectPath).Count != 0) { MsBuildProject = ProjectCollection.GlobalProjectCollection.GetLoadedProjects(fullProjectPath).FirstOrDefault <Project>(); } else { MsBuildProject = new Project(fullProjectPath); } } catch (Exception) { } if (MsBuildProject != null) { FxMoniker = GetTargetFramework(MsBuildProject, priorityFxVersion); FxMonikerString = GetFxMonikerString(priorityFxVersion); ProjectTaskItem = new Microsoft.Build.Utilities.TaskItem(fullProjectPath); FullProjectPath = fullProjectPath; TargetOutputFullPath = GetTargetFullPath(MsBuildProject, FxMonikerString); ProjectType = GetProjectType(MsBuildProject); IsTargetFxSupported = IsFxSupported(FxMonikerString); IsProjectDataPlane = IsDataPlaneProject(MsBuildProject); IsFxFullDesktopVersion = IsExpectedFxCategory(FxMoniker, TargetFxCategory.FullDesktop); IsFxNetCore = IsExpectedFxCategory(FxMoniker, TargetFxCategory.NetCore); ProjectImports = GetProjectImports(MsBuildProject); } } }
public SystemPackageInfo GetPackageInfo() { SystemPackageInfo pi = new SystemPackageInfo(); pi.Name = name; pi.Version = version; if (fxVersion != null) { pi.TargetFramework = TargetFrameworkMoniker.Parse(fxVersion); } else if (clrVersion == ClrVersion.Net_1_1) { pi.TargetFramework = TargetFrameworkMoniker.NET_1_1; } else if (clrVersion == ClrVersion.Net_2_0) { pi.TargetFramework = TargetFrameworkMoniker.NET_2_0; } if (hasGacRoot) { pi.GacRoot = Addin.GetFilePath("."); } return(pi); }
public FakeDotNetProject () { References = new ProjectReferenceCollection (); Files = new ProjectFileCollection (); TargetFrameworkMoniker = new TargetFrameworkMoniker ("v4.5"); CreateEqualsAction (); }
public Task CollectionRulePipeline_DurationLimitTest(TargetFrameworkMoniker appTfm) { ManualTriggerService triggerService = new(); CallbackActionService callbackService = new(_outputHelper); return(ExecuteScenario( appTfm, TestAppScenarios.AsyncWait.Name, TestRuleName, options => { options.CreateCollectionRule(TestRuleName) .SetManualTrigger() .AddAction(CallbackAction.ActionName) .SetDurationLimit(TimeSpan.FromSeconds(3)); }, async(runner, pipeline, _) => { using CancellationTokenSource cancellationSource = new(DefaultPipelineTimeout); // Pipeline should run to completion due to rule duration limit. await pipeline.RunAsync(cancellationSource.Token); await runner.SendCommandAsync(TestAppScenarios.AsyncWait.Commands.Continue); // Action list should not have been executed. VerifyExecutionCount(callbackService, expectedCount: 0); }, services => { services.RegisterManualTrigger(triggerService); services.RegisterTestAction(callbackService); })); }
public FakeDotNetProject() { References = new ProjectReferenceCollection(); Files = new ProjectFileCollection(); TargetFrameworkMoniker = new TargetFrameworkMoniker("v4.5"); CreateEqualsAction(); }
/// <summary> /// defines a new Job that targets specified Framework /// </summary> /// <param name="targetFrameworkMoniker">Target Framework to test.</param> /// <param name="baseline">set to true if you want given Job to be a baseline for multiple runtimes comparison. False by default</param> public TargetFrameworkJobAttribute(TargetFrameworkMoniker targetFrameworkMoniker, bool baseline = false) : base(Job.Default .With(targetFrameworkMoniker.GetToolchain()) .With(targetFrameworkMoniker.GetRuntime()) .WithBaseline(baseline)) { }
/// <summary> /// Used by unit tests. /// </summary> internal static bool IsSupported( TargetFrameworkMoniker projectFramework, DotNetCoreVersion[] versions, bool msbuildSdksInstalled) { if (!projectFramework.IsNetStandardOrNetCoreApp()) { // Allow other frameworks to be supported such as .NET Framework. return(true); } var projectFrameworkVersion = Version.Parse(projectFramework.Version); if (versions.Any(sdkVersion => IsSupported(projectFramework, projectFrameworkVersion, sdkVersion))) { return(true); } // .NET Core <= 2.1 is supported by the MSBuild .NET Core SDKs if they are installed with Mono. if (projectFrameworkVersion <= DotNetCoreVersion2_1) { return(msbuildSdksInstalled); } return(false); }
private async Task PerformTrace(IHost host, TargetFrameworkMoniker tfm) { CollectTraceOptions options = ActionTestsHelper.GetActionOptions <CollectTraceOptions>(host, DefaultRuleName); ICollectionRuleActionFactoryProxy factory; Assert.True(host.Services.GetService <ICollectionRuleActionOperations>().TryCreateFactory(KnownCollectionRuleActions.CollectTrace, out factory)); EndpointInfoSourceCallback callback = new(_outputHelper); await using ServerSourceHolder sourceHolder = await _endpointUtilities.StartServerAsync(callback); AppRunner runner = _endpointUtilities.CreateAppRunner(sourceHolder.TransportName, tfm); Task <IEndpointInfo> newEndpointInfoTask = callback.WaitAddedEndpointInfoAsync(runner, CommonTestTimeouts.StartProcess); await runner.ExecuteAsync(async() => { IEndpointInfo endpointInfo = await newEndpointInfoTask; ICollectionRuleAction action = factory.Create(endpointInfo, options); CollectionRuleActionResult result = await ActionTestsHelper.ExecuteAndDisposeAsync(action, CommonTestTimeouts.TraceTimeout); string egressPath = ActionTestsHelper.ValidateEgressPath(result); using FileStream traceStream = new(egressPath, FileMode.Open, FileAccess.Read); Assert.NotNull(traceStream); await ValidateTrace(traceStream); await runner.SendCommandAsync(TestAppScenarios.AsyncWait.Commands.Continue); }); }
internal static Runtime GetRuntime(this TargetFrameworkMoniker targetFrameworkMoniker) { switch (targetFrameworkMoniker) { case TargetFrameworkMoniker.Net461: case TargetFrameworkMoniker.Net462: case TargetFrameworkMoniker.Net47: case TargetFrameworkMoniker.Net471: case TargetFrameworkMoniker.Net472: case TargetFrameworkMoniker.Net48: return(Runtime.Clr); case TargetFrameworkMoniker.NetCoreApp20: case TargetFrameworkMoniker.NetCoreApp21: case TargetFrameworkMoniker.NetCoreApp22: case TargetFrameworkMoniker.NetCoreApp30: case TargetFrameworkMoniker.NetCoreApp31: case TargetFrameworkMoniker.NetCoreApp50: return(Runtime.Core); case TargetFrameworkMoniker.Mono: return(Runtime.Mono); case TargetFrameworkMoniker.CoreRt: return(Runtime.CoreRT); default: throw new ArgumentOutOfRangeException(nameof(targetFrameworkMoniker), targetFrameworkMoniker, "Target Framework Moniker not supported"); } }
public Task LogsUseAppFiltersViaBodyActionTest(TargetFrameworkMoniker tfm, LogFormat logFormat) { return(ValidateLogsActionAsync( new LogsConfiguration() { LogLevel = LogLevel.Trace, UseAppFilters = true }, async reader => { LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category1DebugEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category1InformationEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category1WarningEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category1ErrorEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category1CriticalEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category2InformationEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category2WarningEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category2ErrorEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category2CriticalEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category3WarningEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category3ErrorEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category3CriticalEntry, await reader.ReadAsync()); Assert.False(await reader.WaitToReadAsync()); }, logFormat, tfm)); }
public Task LogsDefaultLevelFallbackActionTest(TargetFrameworkMoniker tfm, LogFormat logFormat) { return(ValidateLogsActionAsync( new LogsConfiguration() { FilterSpecs = new Dictionary <string, LogLevel?>() { { TestAppScenarios.Logger.Categories.LoggerCategory1, LogLevel.Error }, { TestAppScenarios.Logger.Categories.LoggerCategory2, null }, { TestAppScenarios.Logger.Categories.LoggerCategory3, LogLevel.Warning } }, LogLevel = LogLevel.Information, UseAppFilters = false }, async reader => { LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category1ErrorEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category1CriticalEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category2InformationEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category2WarningEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category2ErrorEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category2CriticalEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category3WarningEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category3ErrorEntry, await reader.ReadAsync()); LogsTestUtilities.ValidateEntry(LogsTestUtilities.Category3CriticalEntry, await reader.ReadAsync()); Assert.False(await reader.WaitToReadAsync()); }, logFormat, tfm)); }
void ReadProject(string frameworkMoniker = ".NETCoreApp,Version=v1.0") { var moniker = TargetFrameworkMoniker.Parse(frameworkMoniker); project.ReadProjectHeader(msbuildProject); project.ReadProject(msbuildProject, moniker); }
public string GetFxMonikerString(TargetFrameworkMoniker fxMoniker) { string monikerString = string.Empty; switch (fxMoniker) { case TargetFrameworkMoniker.net452: monikerString = "net452"; break; case TargetFrameworkMoniker.netcoreapp11: monikerString = "netcoreapp1.1"; break; case TargetFrameworkMoniker.netstandard14: monikerString = "netstandard1.4"; break; case TargetFrameworkMoniker.net46: monikerString = "net46"; break; case TargetFrameworkMoniker.net461: monikerString = "net461"; break; } return(monikerString); }
static NuGetFramework GetNuGetFramework(TargetFrameworkMoniker targetFramework) { return(new NuGetFramework( targetFramework.Identifier, Version.Parse(targetFramework.Version), targetFramework.Profile)); }
private TargetFrameworkMoniker GetFxMoniker(string fx) { string lcMoniker = fx.ToLower(); TargetFrameworkMoniker validMoniker = TargetFrameworkMoniker.UnSupported; switch (lcMoniker) { case "net452": validMoniker = TargetFrameworkMoniker.net452; break; case "netcoreapp1.1": validMoniker = TargetFrameworkMoniker.netcoreapp11; break; case "netstandard1.4": validMoniker = TargetFrameworkMoniker.netstandard14; break; case "net46": validMoniker = TargetFrameworkMoniker.net46; break; case "net461": validMoniker = TargetFrameworkMoniker.net461; break; default: validMoniker = TargetFrameworkMoniker.UnSupported; break; } return(validMoniker); }
public IEnumerable <NuGetReference> GetTransitivePackageReferences(TargetFrameworkMoniker tfm) { if (PackageReferenceFormat != NugetPackageFormat.PackageReference) { return(Enumerable.Empty <NuGetReference>()); } var parsedTfm = NuGetFramework.Parse(tfm.Name); var lockFile = LockFileUtilities.GetLockFile(LockFilePath, NuGet.Common.NullLogger.Instance); if (lockFile is null) { throw new ProjectRestoreRequiredException($"Project is not restored: {FileInfo}"); } var lockFileTarget = lockFile .Targets .FirstOrDefault(t => t.TargetFramework.DotNetFrameworkName.Equals(parsedTfm.DotNetFrameworkName, StringComparison.Ordinal)); if (lockFileTarget is null) { throw new ProjectRestoreRequiredException($"Could not find {parsedTfm.DotNetFrameworkName} in {LockFilePath} for {FileInfo}"); } return(lockFileTarget.Libraries.Select(l => new NuGetReference(l.Name, l.Version.ToNormalizedString()))); }
public void FromProductVersionParsesVersionProperly(TargetFrameworkMoniker expectedTfm, string expectedMsBuildMoniker, string productName, string productVersion) { var runtime = CoreRuntime.FromProductVersion(productVersion, productName); Assert.Equal(expectedTfm, runtime.TargetFrameworkMoniker); Assert.Equal(expectedMsBuildMoniker, runtime.MsBuildMoniker); }
private static bool TryGetMoniker(ITargetFrameworkSelectorFilterState updater, [MaybeNullWhen(false)] out TargetFrameworkMoniker tfm) { var current = updater.Current; if (current.IsNetStandard) { current = updater.AppBase; } // Projects with Windows Desktop components or a WinExe output type should use a -windows suffix if (updater.Components.HasFlag(ProjectComponents.WindowsDesktop) || updater.Project.OutputType == ProjectOutputType.WinExe) { tfm = current with { Platform = TargetFrameworkMoniker.Platforms.Windows }; if (updater.Components.HasFlag(ProjectComponents.WinRT)) { // TODO: Default to this version to ensure everything is supported. tfm = tfm with { PlatformVersion = TargetFrameworkMoniker.Net50_Windows_10_0_19041_0.PlatformVersion }; } return(true); } tfm = null; return(false); } } }
protected override Task OnExecute( ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration) { TargetFrameworkMoniker framework = Project.TargetFramework.Id; if (Project.HasMultipleTargetFrameworks) { var frameworkContext = context?.ExecutionTarget as AspNetCoreTargetFrameworkExecutionTarget; if (frameworkContext != null) { framework = frameworkContext.Framework; if (!(configuration is DotNetProjectFrameworkConfigurationSelector)) { configuration = new DotNetProjectFrameworkConfigurationSelector(configuration, frameworkContext.FrameworkShortName); } } } if (IsSupportedFramework(framework)) { return(OnExecute(monitor, context, configuration, framework, runConfiguration)); } return(base.OnExecute(monitor, context, configuration, runConfiguration)); }
FakeDotNetProject CreateProjectWithTargetFramework(string targetFramework) { var project = new FakeDotNetProject(); project.TargetFrameworkMoniker = TargetFrameworkMoniker.Parse(targetFramework); return(project); }
/// <summary> /// Chooses the most likely target TFM a project should be retargeted to based on its style, output type, dependencies, and /// the user's preference of current or LTS. /// </summary> public TargetFrameworkMoniker SelectTFM(IProject project) { if (project is null) { throw new ArgumentNullException(nameof(project)); } var tfmName = GetNetStandardTFM(project); // Projects with web components or an Exe output type should use app TFMs if (project.Components.HasFlag(ProjectComponents.AspNet) || project.Components.HasFlag(ProjectComponents.AspNetCore) || project.OutputType == ProjectOutputType.Exe) { tfmName = AppTFMBase; } // Projects with Windows Desktop components or a WinExe output type should use a -windows suffix if (project.Components.HasFlag(ProjectComponents.WindowsDesktop) || project.OutputType == ProjectOutputType.WinExe) { tfmName = $"{AppTFMBase}{WindowsSuffix}"; if (project.Components.HasFlag(ProjectComponents.WinRT)) { // TODO: Default to this version to ensure everything is supported. tfmName += "10.0.19041.0"; } } _logger.LogDebug("Considering TFM {TFM} for project {Project} based on its style and output type ({ProjectStyle}, {ProjectOutputType})", tfmName, project.FilePath, project.Components, project.OutputType); // If the project depends on another project with a higher version NetCore or NetStandard TFM, // use that TFM instead. var tfm = new TargetFrameworkMoniker(tfmName); foreach (var dep in project.ProjectReferences) { try { if (_tfmComparer.IsCompatible(tfm, dep.TFM)) { continue; } if (dep.TFM.IsNetCore || dep.TFM.IsNetStandard) { tfm = dep.TFM; _logger.LogDebug("Considering TFM {TFM} for project {Project} based on its dependency on {DepProject}", tfm, project.FilePath, dep.FilePath); } } catch (UpgradeException) { _logger.LogWarning($"Unable to determine TFM for dependency {dep.FilePath}; TFM for {project.FilePath} may not be correct."); } } _logger.LogDebug("Recommending TFM {TFM} for project {Project}", tfm, project.FilePath); // Ensure we don't downgrade a project return(_tfmComparer.Compare(project.TFM, tfm) > 0 ? project.TFM : tfm); }
public SdkProjectMetaData(ITaskItem project, TargetFrameworkMoniker fxMoniker, string fullProjectPath, bool isTargetFxSupported, SdkProjctType projectType = SdkProjctType.Sdk) { ProjectTaskItem = project; FxMoniker = fxMoniker; FullProjectPath = fullProjectPath; IsTargetFxSupported = isTargetFxSupported; ProjectType = projectType; }
public OutProcSpecFlowConnector(DeveroomConfiguration configuration, IDeveroomLogger logger, TargetFrameworkMoniker targetFrameworkMoniker, string extensionFolder, ProcessorArchitectureSetting processorArchitecture) { _configuration = configuration; _logger = logger; _targetFrameworkMoniker = targetFrameworkMoniker; _extensionFolder = extensionFolder; _processorArchitecture = processorArchitecture; }
protected override ExecutionCommand OnCreateExecutionCommand( ConfigurationSelector configSel, DotNetProjectConfiguration configuration, TargetFrameworkMoniker framework, ProjectRunConfiguration runConfiguration) { return(CreateDotNetCoreExecutionCommand(configSel, configuration, runConfiguration)); }
public FilterState(ITargetFrameworkMonikerComparer comparer, IProject project, TargetFrameworkMoniker current, TargetFrameworkMoniker appbase, ILogger logger) { _comparer = comparer; Project = project; Current = current; AppBase = appbase; _logger = logger; }
public async Task TestGetEnvVar(TargetFrameworkMoniker tfm) { const string VariableDoesNotExist = "SomeEnvVarThatIsNotSet"; await TestHostHelper.CreateCollectionRulesHost( outputHelper : _outputHelper, setup : (Tools.Monitor.RootOptions rootOptions) => { rootOptions.CreateCollectionRule(DefaultRuleName) .SetStartupTrigger() .AddGetEnvironmentVariableAction(TestAppScenarios.EnvironmentVariables.IncrementVariableName) .AddGetEnvironmentVariableAction(VariableDoesNotExist); }, hostCallback : async(Extensions.Hosting.IHost host) => { GetEnvironmentVariableOptions getOpts = ActionTestsHelper.GetActionOptions <GetEnvironmentVariableOptions>(host, DefaultRuleName, 0); GetEnvironmentVariableOptions getFailOpts = ActionTestsHelper.GetActionOptions <GetEnvironmentVariableOptions>(host, DefaultRuleName, 1); ICollectionRuleActionOperations actionOperationsService = host.Services.GetService <ICollectionRuleActionOperations>(); Assert.True(actionOperationsService.TryCreateFactory(KnownCollectionRuleActions.GetEnvironmentVariable, out ICollectionRuleActionFactoryProxy getFactory)); EndpointInfoSourceCallback endpointInfoCallback = new(_outputHelper); await using ServerSourceHolder sourceHolder = await _endpointUtilities.StartServerAsync(endpointInfoCallback); AppRunner runner = _endpointUtilities.CreateAppRunner(sourceHolder.TransportName, tfm); runner.ScenarioName = TestAppScenarios.EnvironmentVariables.Name; Task <IEndpointInfo> newEndpointInfoTask = endpointInfoCallback.WaitAddedEndpointInfoAsync(runner, CommonTestTimeouts.StartProcess); await runner.ExecuteAsync(async() => { IEndpointInfo endpointInfo = await newEndpointInfoTask; ICollectionRuleAction getAction = getFactory.Create(endpointInfo, getOpts); await runner.SendCommandAsync(TestAppScenarios.EnvironmentVariables.Commands.IncVar); Assert.Equal("1", await runner.GetEnvironmentVariable(TestAppScenarios.EnvironmentVariables.IncrementVariableName, CommonTestTimeouts.EnvVarsTimeout)); await runner.SendCommandAsync(TestAppScenarios.EnvironmentVariables.Commands.IncVar); Assert.Equal("2", await runner.GetEnvironmentVariable(TestAppScenarios.EnvironmentVariables.IncrementVariableName, CommonTestTimeouts.EnvVarsTimeout)); CollectionRuleActionResult result = await ActionTestsHelper.ExecuteAndDisposeAsync(getAction, CommonTestTimeouts.EnvVarsTimeout); Assert.Equal("2", result.OutputValues[CollectionRuleActionConstants.EnvironmentVariableValueName]); await runner.SendCommandAsync(TestAppScenarios.EnvironmentVariables.Commands.IncVar); Assert.Equal("3", await runner.GetEnvironmentVariable(TestAppScenarios.EnvironmentVariables.IncrementVariableName, CommonTestTimeouts.EnvVarsTimeout)); ICollectionRuleAction getActionFailure = getFactory.Create(endpointInfo, getFailOpts); CollectionRuleActionException thrownEx = await Assert.ThrowsAsync <CollectionRuleActionException>(async() => { await ActionTestsHelper.ExecuteAndDisposeAsync(getActionFailure, CommonTestTimeouts.EnvVarsTimeout); }); Assert.Contains(VariableDoesNotExist, thrownEx.Message); await runner.SendCommandAsync(TestAppScenarios.EnvironmentVariables.Commands.ShutdownScenario); }); }); }
internal TargetFramework (TargetFrameworkMoniker id) { this.id = id; this.name = id.Profile == null ? string.Format ("{0} {1}", id.Identifier, id.Version) : string.Format ("{0} {1} {2} Profile", id.Identifier, id.Version, id.Profile); clrVersion = ClrVersion.Default; Assemblies = new AssemblyInfo[0]; }
public void TryGetVersionFromProductInfoHandlesValidInput(TargetFrameworkMoniker expectedTfm, string expectedMsBuildMoniker, string productName, string productVersion) { Assert.True(CoreRuntime.TryGetVersionFromProductInfo(productVersion, productName, out Version version)); var runtime = CoreRuntime.FromVersion(version); Assert.Equal(expectedTfm, runtime.TargetFrameworkMoniker); Assert.Equal(expectedMsBuildMoniker, runtime.MsBuildMoniker); }
public AppRunner CreateAppRunner(string transportName, TargetFrameworkMoniker tfm, int appId = 1) { AppRunner appRunner = new(_outputHelper, Assembly.GetExecutingAssembly(), appId, tfm); appRunner.ConnectionMode = DiagnosticPortConnectionMode.Connect; appRunner.DiagnosticPortPath = transportName; appRunner.ScenarioName = TestAppScenarios.AsyncWait.Name; return(appRunner); }
public MSBuildFileFormat (string productVersion, string toolsVersion, string slnVersion, string productDescription, TargetFrameworkMoniker[] frameworkVersions, bool supportsMonikers) { this.productVersion = productVersion; this.toolsVersion = toolsVersion; this.slnVersion = slnVersion; this.productDescription = productDescription; this.frameworkVersions = frameworkVersions; this.supportsMonikers = supportsMonikers; }
internal void Initialize (SystemPackageInfo info, IEnumerable<SystemAssembly> assemblies, bool isInternal) { this.isInternal = isInternal; this.name = info.Name ?? string.Empty; this.version = info.Version ?? string.Empty; this.description = info.Description ?? string.Empty; this.targetFramework = info.TargetFramework; this.gacRoot = info.GacRoot; this.gacPackage = info.IsGacPackage; IsFrameworkPackage = info.IsFrameworkPackage; IsCorePackage = info.IsCorePackage; this.Requires = info.Requires; SystemAssembly last = null; foreach (SystemAssembly asm in assemblies) { if (asm == null) continue; asm.Package = this; if (this.assemblies == null) this.assemblies = asm; else last.NextSamePackage = asm; last = asm; } }
async Task CreateNuGetPackagingProject (ProgressMonitor monitor) { FilePath projectFileName = GetNewProjectFileName ("NuGetPackaging"); packagingProject = Services.ProjectService.CreateProject ("NuGetPackaging") as PackagingProject; packagingProject.FileName = projectFileName; var createInfo = CreateProjectCreateInformation (projectFileName); packagingProject.InitializeFromTemplate (createInfo, CreateProjectOptions ()); var moniker = new TargetFrameworkMoniker (TargetFrameworkMoniker.ID_NET_FRAMEWORK, "4.5", null); packagingProject.TargetFramework = Runtime.SystemAssemblyService.GetTargetFramework (moniker); MoveNuGetPackageMetadataToPackagingProject (); await Project.SaveAsync (monitor); Project.ParentFolder.AddItem (packagingProject); AddNuGetPackagingProjectReferences (); await SaveProject (monitor, packagingProject); }
public TargetFramework GetTargetFramework (TargetFrameworkMoniker id) { TargetFramework fx; if (frameworks.TryGetValue (id, out fx)) return fx; LoggingService.LogWarning ("Unregistered TargetFramework '{0}' is being requested from SystemAssemblyService", id); UpdateFrameworks (new [] { new TargetFramework (id) }); return frameworks [id]; }
static TargetFramework ReadTargetFramework (TargetFrameworkMoniker moniker, FilePath directory) { try { return TargetFramework.FromFrameworkDirectory (moniker, directory); } catch (Exception ex) { LoggingService.LogError ("Error reading framework definition '" + directory + "'", ex); } return null; }
public bool IncludesFramework (TargetFrameworkMoniker id) { return id == this.id || includedFrameworks.Contains (id); }
public TargetFramework GetTargetFramework (TargetFrameworkMoniker id) { foreach (TargetFramework fx in frameworks) if (fx.Id == id) return fx; LoggingService.LogWarning ("Unregistered TargetFramework '{0}' is being requested from SystemAssemblyService", id); TargetFramework f = new TargetFramework (id); frameworks.Add (f); return f; }
public bool IsCompatibleWithFramework (TargetFrameworkMoniker fxId) { return fxId.Identifier == this.id.Identifier && new Version (fxId.Version).CompareTo (new Version (this.id.Version)) <= 0; }
public static TargetFramework FromFrameworkDirectory (TargetFrameworkMoniker moniker, FilePath dir) { var fxList = dir.Combine ("RedistList", "FrameworkList.xml"); if (!System.IO.File.Exists (fxList)) return null; var fx = new TargetFramework (moniker); using (var reader = System.Xml.XmlReader.Create (fxList)) { if (!reader.ReadToDescendant ("FileList")) throw new Exception ("Missing FileList element"); //not sure what this is for //if (reader.MoveToAttribute ("Redist") && reader.ReadAttributeValue ()) // redist = reader.ReadContentAsString (); if (reader.MoveToAttribute ("Name") && reader.ReadAttributeValue ()) fx.name = reader.ReadContentAsString (); if (reader.MoveToAttribute ("RuntimeVersion") && reader.ReadAttributeValue ()) { string runtimeVersion = reader.ReadContentAsString (); switch (runtimeVersion) { case "2.0": fx.clrVersion = ClrVersion.Net_2_0; break; case "4.0": fx.clrVersion = ClrVersion.Net_4_0; break; default: throw new Exception ("Unknown RuntimeVersion '" + runtimeVersion + "'"); } } if (reader.MoveToAttribute ("ToolsVersion") && reader.ReadAttributeValue ()) { string runtimeVersion = reader.ReadContentAsString (); switch (runtimeVersion) { case "2.0": fx.toolsVersion = TargetFrameworkToolsVersion.V2_0; break; case "3.5": fx.toolsVersion = TargetFrameworkToolsVersion.V3_5; break; case "4.0": fx.toolsVersion = TargetFrameworkToolsVersion.V4_0; break; default: throw new Exception ("Unknown ToolsVersion '" + runtimeVersion + "'"); } } if (reader.MoveToAttribute ("IncludeFramework") && reader.ReadAttributeValue ()) { string include = reader.ReadContentAsString (); if (!string.IsNullOrEmpty (include)) { fx.IncludedFrameworks.Add (new TargetFrameworkMoniker (fx.Id.Identifier, include)); } } var assemblies = new List<AssemblyInfo> (); if (reader.ReadToFollowing ("File")) { do { var ainfo = new AssemblyInfo (); assemblies.Add (ainfo); if (reader.MoveToAttribute ("AssemblyName") && reader.ReadAttributeValue ()) ainfo.Name = reader.ReadContentAsString (); if (string.IsNullOrEmpty (ainfo.Name)) throw new Exception ("Missing AssemblyName attribute"); if (reader.MoveToAttribute ("Version") && reader.ReadAttributeValue ()) ainfo.Version = reader.ReadContentAsString (); if (reader.MoveToAttribute ("PublicKeyToken") && reader.ReadAttributeValue ()) ainfo.PublicKeyToken = reader.ReadContentAsString (); if (reader.MoveToAttribute ("Culture") && reader.ReadAttributeValue ()) ainfo.Culture = reader.ReadContentAsString (); if (reader.MoveToAttribute ("ProcessorArchitecture") && reader.ReadAttributeValue ()) ainfo.ProcessorArchitecture = (ProcessorArchitecture) Enum.Parse (typeof (ProcessorArchitecture), reader.ReadContentAsString (), true); if (reader.MoveToAttribute ("InGac") && reader.ReadAttributeValue ()) ainfo.InGac = reader.ReadContentAsBoolean (); } while (reader.ReadToFollowing ("File")); } else { var files = System.IO.Directory.GetFiles (dir, "*.dll"); foreach (var f in files) { try { var an = SystemAssemblyService.GetAssemblyNameObj (dir.Combine (f)); var ainfo = new AssemblyInfo (); ainfo.Update (an); assemblies.Add (ainfo); } catch (Exception ex) { LoggingService.LogError ("Error reading name for assembly '{0}' in framework '{1}':\n{2}", f, fx.Id, ex.ToString ()); } } } fx.Assemblies = assemblies.ToArray (); } return fx; }
static TargetFramework GetTargetFramework (TargetFrameworkMoniker id, Dictionary<TargetFrameworkMoniker, TargetFramework> frameworks) { TargetFramework fx; if (frameworks.TryGetValue (id, out fx)) return fx; LoggingService.LogWarning ("Unregistered TargetFramework '{0}' is being requested from SystemAssemblyService", id); fx = new TargetFramework (id); frameworks[id] = fx; return fx; }
//HACK: this is so that MonoTargetRuntime can access the core frameworks while it's doing its broken assembly->framework mapping internal TargetFramework GetCoreFramework (TargetFrameworkMoniker id) { return GetTargetFramework (id, frameworks); }
public TargetFramework GetTargetFramework (TargetFrameworkMoniker id) { return GetTargetFramework (id, frameworks); }
public static TargetFramework FromFrameworkDirectory (TargetFrameworkMoniker moniker, FilePath dir) { var fxList = dir.Combine ("RedistList", "FrameworkList.xml"); if (!File.Exists (fxList)) return null; var fx = new TargetFramework (moniker); using (var reader = System.Xml.XmlReader.Create (fxList)) { if (!reader.ReadToDescendant ("FileList")) throw new Exception ("Missing FileList element"); //not sure what this is for //if (reader.MoveToAttribute ("Redist") && reader.ReadAttributeValue ()) // redist = reader.ReadContentAsString (); if (reader.MoveToAttribute ("Name") && reader.ReadAttributeValue ()) fx.name = reader.ReadContentAsString (); if (reader.MoveToAttribute ("RuntimeVersion") && reader.ReadAttributeValue ()) { string runtimeVersion = reader.ReadContentAsString (); switch (runtimeVersion) { case "2.0": fx.clrVersion = ClrVersion.Net_2_0; break; case "4.0": fx.clrVersion = ClrVersion.Net_4_0; break; case "4.5": case "4.5.1": fx.clrVersion = ClrVersion.Net_4_5; break; default: LoggingService.LogInfo ("Framework {0} has unknown RuntimeVersion {1}", moniker, runtimeVersion); return null; } } if (reader.MoveToAttribute ("ToolsVersion") && reader.ReadAttributeValue ()) { string toolsVersion = reader.ReadContentAsString (); switch (toolsVersion) { case "2.0": fx.toolsVersion = TargetFrameworkToolsVersion.V2_0; break; case "3.5": fx.toolsVersion = TargetFrameworkToolsVersion.V3_5; break; case "4.0": fx.toolsVersion = TargetFrameworkToolsVersion.V4_0; break; case "4.5": fx.toolsVersion = TargetFrameworkToolsVersion.V4_5; break; default: LoggingService.LogInfo ("Framework {0} has unknown ToolsVersion {1}", moniker, toolsVersion); return null; } } if (reader.MoveToAttribute ("IncludeFramework") && reader.ReadAttributeValue ()) { string include = reader.ReadContentAsString (); if (!string.IsNullOrEmpty (include)) { fx.IncludedFrameworks.Add (new TargetFrameworkMoniker (fx.Id.Identifier, include)); } } //this is a Mono-specific extension if (reader.MoveToAttribute ("TargetFrameworkDirectory") && reader.ReadAttributeValue ()) { string targetDir = reader.ReadContentAsString (); if (!string.IsNullOrEmpty (targetDir)) { targetDir = targetDir.Replace ('\\', System.IO.Path.DirectorySeparatorChar); dir = fxList.ParentDirectory.Combine (targetDir).FullPath; } } var assemblies = new List<AssemblyInfo> (); if (reader.ReadToFollowing ("File")) { do { var ainfo = new AssemblyInfo (); assemblies.Add (ainfo); if (reader.MoveToAttribute ("AssemblyName") && reader.ReadAttributeValue ()) ainfo.Name = reader.ReadContentAsString (); if (string.IsNullOrEmpty (ainfo.Name)) throw new Exception ("Missing AssemblyName attribute"); if (reader.MoveToAttribute ("Version") && reader.ReadAttributeValue ()) ainfo.Version = reader.ReadContentAsString (); if (reader.MoveToAttribute ("PublicKeyToken") && reader.ReadAttributeValue ()) ainfo.PublicKeyToken = reader.ReadContentAsString (); if (reader.MoveToAttribute ("Culture") && reader.ReadAttributeValue ()) ainfo.Culture = reader.ReadContentAsString (); if (reader.MoveToAttribute ("ProcessorArchitecture") && reader.ReadAttributeValue ()) ainfo.ProcessorArchitecture = (ProcessorArchitecture) Enum.Parse (typeof (ProcessorArchitecture), reader.ReadContentAsString (), true); if (reader.MoveToAttribute ("InGac") && reader.ReadAttributeValue ()) ainfo.InGac = reader.ReadContentAsBoolean (); } while (reader.ReadToFollowing ("File")); } else { // HACK: we were using EnumerateFiles but it's broken in some Mono releases // https://bugzilla.xamarin.com/show_bug.cgi?id=2975 var files = System.IO.Directory.GetFiles (dir, "*.dll"); foreach (var f in files) { try { var an = SystemAssemblyService.GetAssemblyNameObj (dir.Combine (f)); var ainfo = new AssemblyInfo (); ainfo.Update (an); assemblies.Add (ainfo); } catch (Exception ex) { LoggingService.LogError ("Error reading name for assembly '{0}' in framework '{1}':\n{2}", f, fx.Id, ex.ToString ()); } } } fx.Assemblies = assemblies.ToArray (); } var supportedFrameworksDir = dir.Combine ("SupportedFrameworks"); if (Directory.Exists (supportedFrameworksDir)) { foreach (var sfx in Directory.GetFiles (supportedFrameworksDir)) fx.SupportedFrameworks.Add (SupportedFramework.Load (fx, sfx)); } return fx; }
public TargetFramework GetTargetFramework (TargetFrameworkMoniker id) { EnsureRuntimesInitialized (); return GetTargetFramework (id, frameworks); }
internal bool IsKnownFramework (TargetFrameworkMoniker moniker) { return frameworks.ContainsKey (moniker); }
public bool CanReferenceAssembliesTargetingFramework (TargetFrameworkMoniker fxId) { var fx = Runtime.SystemAssemblyService.GetTargetFramework (fxId); return fx != null && CanReferenceAssembliesTargetingFramework (fx); }
public TargetFramework GetTargetFramework (TargetFrameworkMoniker id) { TargetFramework fx; if (frameworks.TryGetValue (id, out fx)) return fx; LoggingService.LogDebug ("Unregistered TargetFramework '{0}' is being requested from SystemAssemblyService, ensuring rutimes initialized and trying again", id); foreach (var r in runtimes) r.EnsureInitialized (); if (frameworks.TryGetValue (id, out fx)) return fx; LoggingService.LogWarning ("Unregistered TargetFramework '{0}' is being requested from SystemAssemblyService, returning empty TargetFramework", id); UpdateFrameworks (new [] { new TargetFramework (id) }); return frameworks [id]; }
public static TargetFramework FromFrameworkDirectory (TargetFrameworkMoniker moniker, FilePath dir) { var fxList = dir.Combine ("RedistList", "FrameworkList.xml"); if (!File.Exists (fxList)) return null; var fx = new TargetFramework (moniker); using (var reader = System.Xml.XmlReader.Create (fxList)) { if (!reader.ReadToDescendant ("FileList")) throw new Exception ("Missing FileList element"); //not sure what this is for //if (reader.MoveToAttribute ("Redist") && reader.ReadAttributeValue ()) // redist = reader.ReadContentAsString (); if (reader.MoveToAttribute ("Name") && reader.ReadAttributeValue ()) fx.name = reader.ReadContentAsString (); if (reader.MoveToAttribute ("RuntimeVersion") && reader.ReadAttributeValue ()) { string runtimeVersion = reader.ReadContentAsString (); switch (runtimeVersion) { case "2.0": fx.clrVersion = ClrVersion.Net_2_0; break; case "4.0": fx.clrVersion = ClrVersion.Net_4_0; break; //The concept of "ClrVersion" breaks down hard after 4.5 and is essentially meaningless default: fx.clrVersion = ClrVersion.Net_4_5; break; } } if (reader.MoveToAttribute ("ToolsVersion") && reader.ReadAttributeValue ()) { string toolsVersion = reader.ReadContentAsString (); switch (toolsVersion) { case "2.0": fx.toolsVersion = TargetFrameworkToolsVersion.V2_0; break; case "3.5": fx.toolsVersion = TargetFrameworkToolsVersion.V3_5; break; case "4.0": fx.toolsVersion = TargetFrameworkToolsVersion.V4_0; break; case "4.5": fx.toolsVersion = TargetFrameworkToolsVersion.V4_5; break; default: LoggingService.LogInfo ("Framework {0} has unknown ToolsVersion {1}", moniker, toolsVersion); return null; } } if (reader.MoveToAttribute ("IncludeFramework") && reader.ReadAttributeValue ()) { string include = reader.ReadContentAsString (); if (!string.IsNullOrEmpty (include)) fx.includesFramework = include; } //this is a Mono-specific extension if (reader.MoveToAttribute ("TargetFrameworkDirectory") && reader.ReadAttributeValue ()) { string targetDir = reader.ReadContentAsString (); if (!string.IsNullOrEmpty (targetDir)) { targetDir = targetDir.Replace ('\\', System.IO.Path.DirectorySeparatorChar); dir = fxList.ParentDirectory.Combine (targetDir).FullPath; } } var assemblies = new List<AssemblyInfo> (); if (reader.ReadToFollowing ("File")) { do { var ainfo = new AssemblyInfo (); assemblies.Add (ainfo); if (reader.MoveToAttribute ("AssemblyName") && reader.ReadAttributeValue ()) ainfo.Name = reader.ReadContentAsString (); if (string.IsNullOrEmpty (ainfo.Name)) throw new Exception ("Missing AssemblyName attribute"); if (reader.MoveToAttribute ("Version") && reader.ReadAttributeValue ()) ainfo.Version = reader.ReadContentAsString (); if (reader.MoveToAttribute ("PublicKeyToken") && reader.ReadAttributeValue ()) ainfo.PublicKeyToken = reader.ReadContentAsString (); if (reader.MoveToAttribute ("Culture") && reader.ReadAttributeValue ()) ainfo.Culture = reader.ReadContentAsString (); if (reader.MoveToAttribute ("ProcessorArchitecture") && reader.ReadAttributeValue ()) ainfo.ProcessorArchitecture = (ProcessorArchitecture) Enum.Parse (typeof (ProcessorArchitecture), reader.ReadContentAsString (), true); if (reader.MoveToAttribute ("InGac") && reader.ReadAttributeValue ()) ainfo.InGac = reader.ReadContentAsBoolean (); } while (reader.ReadToFollowing ("File")); } else if (Directory.Exists (dir)) { foreach (var f in Directory.EnumerateFiles (dir, "*.dll")) { try { var an = SystemAssemblyService.GetAssemblyNameObj (dir.Combine (f)); var ainfo = new AssemblyInfo (); ainfo.Update (an); assemblies.Add (ainfo); } catch (BadImageFormatException ex) { LoggingService.LogError ("Invalid assembly in framework '{0}': {1}{2}{3}", fx.Id, f, Environment.NewLine, ex.ToString ()); } catch (Exception ex) { LoggingService.LogError ("Error reading assembly '{0}' in framework '{1}':{2}{3}", f, fx.Id, Environment.NewLine, ex.ToString ()); } } } fx.Assemblies = assemblies.ToArray (); } var supportedFrameworksDir = dir.Combine ("SupportedFrameworks"); if (Directory.Exists (supportedFrameworksDir)) { foreach (var sfx in Directory.GetFiles (supportedFrameworksDir)) fx.SupportedFrameworks.Add (SupportedFramework.Load (fx, sfx)); } return fx; }
protected override void OnReadProjectHeader (ProgressMonitor monitor, MSBuildProject msproject) { base.OnReadProjectHeader (monitor, msproject); compileTarget = msproject.EvaluatedProperties.GetValue<CompileTarget> ("OutputType"); defaultNamespace = msproject.EvaluatedProperties.GetValue ("RootNamespace", string.Empty); usePartialTypes = msproject.EvaluatedProperties.GetValue ("UsePartialTypes", true); string frameworkIdentifier = msproject.EvaluatedProperties.GetValue ("TargetFrameworkIdentifier"); string frameworkVersion = msproject.EvaluatedProperties.GetValue ("TargetFrameworkVersion"); string frameworkProfile = msproject.EvaluatedProperties.GetValue ("TargetFrameworkProfile"); //determine the default target framework from the project type's default //overridden by the components in the project var def = GetDefaultTargetFrameworkForFormat (ToolsVersion); var targetFx = new TargetFrameworkMoniker ( string.IsNullOrEmpty (frameworkIdentifier)? def.Identifier : frameworkIdentifier, string.IsNullOrEmpty (frameworkVersion)? def.Version : frameworkVersion, string.IsNullOrEmpty (frameworkProfile)? def.Profile : frameworkProfile); string fx = ExtendedProperties ["InternalTargetFrameworkVersion"] as string; if (!string.IsNullOrEmpty (fx)) { targetFx = TargetFrameworkMoniker.Parse (fx); ExtendedProperties.Remove ("InternalTargetFrameworkVersion"); } TargetFramework = Runtime.SystemAssemblyService.GetTargetFramework (targetFx); }
protected static IEnumerable<TargetFramework> FindTargetFrameworks (FilePath frameworksDirectory, bool rescanKnownFrameworks) { foreach (FilePath idDir in Directory.GetDirectories (frameworksDirectory)) { var id = idDir.FileName; foreach (FilePath versionDir in Directory.GetDirectories (idDir)) { var version = versionDir.FileName; var moniker = new TargetFrameworkMoniker (id, version); if (rescanKnownFrameworks || !Runtime.SystemAssemblyService.IsKnownFramework (moniker)) { var fx = ReadTargetFramework (moniker, versionDir); if (fx != null) yield return (fx); } var profileListDir = versionDir.Combine ("Profile"); if (!Directory.Exists (profileListDir)) continue; foreach (FilePath profileDir in Directory.GetDirectories (profileListDir)) { var profile = profileDir.FileName; moniker = new TargetFrameworkMoniker (id, version, profile); if (rescanKnownFrameworks || !Runtime.SystemAssemblyService.IsKnownFramework (moniker)) { var fx = ReadTargetFramework (moniker, profileDir); if (fx != null) yield return (fx); } } } } }
bool HackyCheckForPLPCompatibility (TargetFrameworkMoniker fxId) { int profile, this_profile; if (fxId.Profile == null || fxId.Profile.Length < 8 || !int.TryParse (fxId.Profile.Substring (7), out profile)) return false; switch (this.id.Identifier) { case TargetFrameworkMoniker.ID_NET_FRAMEWORK: if (new Version (fxId.Version).CompareTo (new Version (this.id.Version)) > 0) return false; return profile >= 1 && profile <= 3; // Profile4 does not support .NETFramework case TargetFrameworkMoniker.ID_MONOTOUCH: case TargetFrameworkMoniker.ID_MONODROID: return profile >= 1 && profile <= 3; case TargetFrameworkMoniker.ID_PORTABLE: if (this.id.Profile == null || this.id.Profile.Length < 8 || !int.TryParse (this.id.Profile.Substring (7), out this_profile)) return false; switch (this_profile) { case 1: return true; case 2: return profile == 2; case 3: return profile == 3; case 4: return profile == 4; default: return false; } default: return false; } }
public bool IsCompatibleWithFramework (TargetFrameworkMoniker fxId) { // FIXME: this is a hack which should really be done using the xml definitions for each .NETPortable profile if (fxId.Identifier == ".NETPortable" && fxId.Version == "4.0") return HackyCheckForPLPCompatibility (fxId); return fxId.Identifier == this.id.Identifier && new Version (fxId.Version).CompareTo (new Version (this.id.Version)) <= 0; }
public string GenerateDatabase (string runtimeId, TargetFrameworkMoniker fxId, string baseDir, string assemblyFile) { try { Runtime.Initialize (false); ParserDatabase pdb = new ParserDatabase (); TargetRuntime runtime = Runtime.SystemAssemblyService.GetTargetRuntime (runtimeId); if (runtime == null) LoggingService.LogError ("Runtime '{0}' not found", runtimeId); TargetFramework fx = Runtime.SystemAssemblyService.GetTargetFramework (fxId); // Generate the new db in a temp file. The main process will move the file if required. using (var db = new AssemblyCodeCompletionDatabase (runtime, fx, assemblyFile, pdb, true)) { if (db.LoadError) throw new InvalidOperationException ("Could find assembly: " + assemblyFile); db.ParseInExternalProcess = false; db.ParseAll (); db.Write (); return db.RealDataFile; } } catch (Exception ex) { Console.WriteLine (ex); return null; } }
TargetFramework GetTargetFrameworkForNewProject (XmlElement projectOptions, TargetFrameworkMoniker defaultMoniker) { if (projectOptions == null) return Runtime.SystemAssemblyService.GetTargetFramework (defaultMoniker); var att = projectOptions.Attributes ["TargetFrameworkVersion"]; if (att == null) { att = projectOptions.Attributes ["TargetFramework"]; if (att == null) return Runtime.SystemAssemblyService.GetTargetFramework (defaultMoniker); } var moniker = TargetFrameworkMoniker.Parse (att.Value); //if the string did not include a framework identifier, use the project's default var netID = TargetFrameworkMoniker.ID_NET_FRAMEWORK; if (moniker.Identifier == netID && !att.Value.StartsWith (netID, StringComparison.Ordinal)) moniker = new TargetFrameworkMoniker (defaultMoniker.Identifier, moniker.Version, moniker.Profile); return Runtime.SystemAssemblyService.GetTargetFramework (moniker); }
public bool IsCompatibleWithFramework (TargetFrameworkMoniker fxId) { return CanReferenceAssembliesTargetingFramework (fxId); }
public ReferenceAssemblyFramework (TargetFrameworkMoniker targetFramework) { Include = targetFramework.ToString (); }
static string GetPclProfileFullName (TargetFrameworkMoniker tfm) { if (tfm.Identifier != TargetFrameworkMoniker.ID_PORTABLE) { return null; } //nuget only accepts pcls with a profile number if (tfm.Profile == null || !tfm.Profile.StartsWith ("Profile", StringComparison.Ordinal)) { return null; } return tfm.ToString (); }