private static string GetToolVersionValue(MSBuildVersion toolVersion) { switch (toolVersion) { case MSBuildVersion.MSBuild20: return("2.0"); case MSBuildVersion.MSBuild35: return("3.5"); case MSBuildVersion.MSBuild4: return("4.0"); case MSBuildVersion.MSBuild12: return("12.0"); case MSBuildVersion.MSBuild14: return("14.0"); case MSBuildVersion.MSBuild15: return("15.0"); case MSBuildVersion.MSBuild16: return("16.0"); case MSBuildVersion.MSBuild17: return("17.0"); default: throw new ArgumentOutOfRangeException(nameof(toolVersion), toolVersion, "Invalid value"); } }
/// <summary> /// Constructs the builder /// </summary> /// <param name="slnBuilder">Sub task building the solution file, used as a dependency</param> /// <param name="slnPath">Path of the generated solution file</param> /// <param name="version">MSBuild version to use</param> /// <param name="targetRoot">Target directory</param> /// <param name="msbuildFactory">Factory to get the MSBuild implementation to use</param> public MSBuildRunner(SlnBuilder slnBuilder, TargetRelativePath slnPath, MSBuildVersion version, [TargetRoot] IFileSystemDirectory targetRoot, IMSBuildFactory msbuildFactory) { this.slnBuilder = slnBuilder; this.slnPath = slnPath; this.targetRoot = targetRoot; msbuild = msbuildFactory.CreateMSBuild(version); }
private string GetMSBuildPath() { if (MSBuildVersion == "NotApplicable") { throw new InvalidOperationException($"Parameter 'MSBuildVersion' is set to 'NotApplicable'"); } string msBuildPath; if (MSBuildVersion.StartsWith("14", StringComparison.OrdinalIgnoreCase)) { msBuildPath = Path.Combine( System.Environment.GetEnvironmentVariable("ProgramFiles(x86)"), "MSBuild", "14.0", "Bin", "MSBuild.exe"); } else if (MSBuildVersion.StartsWith("15", StringComparison.OrdinalIgnoreCase)) { var vsPath = Path.Combine( System.Environment.GetEnvironmentVariable("ProgramFiles(x86)"), "Microsoft Visual Studio", GetVSVersion(MSBuildVersion)); var buildToolsPath = Path.Combine(vsPath, "BuildTools"); if (!Directory.Exists(buildToolsPath)) { buildToolsPath = Path.Combine(vsPath, "Enterprise"); } if (!Directory.Exists(buildToolsPath)) { throw new InvalidOperationException($"Could not find MSBuild.exe under {vsPath}"); } msBuildPath = Path.Combine( buildToolsPath, "MSBuild", "15.0", "Bin", "MSBuild.exe"); } else { throw new InvalidOperationException($"Unknown MSBuild version: {MSBuildVersion}"); } // Verify version var output = Util.RunProcess(msBuildPath, "/nologo /version", RootTempDir); if (!output.Trim().Equals(MSBuildVersion, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException($"Incorrect MSBuild version: {output}"); } return(msBuildPath); }
private static string GetVersionFolder(MSBuildVersion version) { return(version switch { MSBuildVersion.VS2013 => "12.0", MSBuildVersion.VS2015 => "14.0", MSBuildVersion.VS2017 => "15.0", _ => "Current" });
private static string GetVersionFolder(MSBuildVersion version) { return(version switch { MSBuildVersion.VS2019 => "Current", MSBuildVersion.VS2017 => "15.0", MSBuildVersion.VS2015 => "14.0", MSBuildVersion.VS2013 => "12.0", _ => throw new ArgumentOutOfRangeException(nameof(version), version, message: null) });
public IMSBuild CreateMSBuild(MSBuildVersion version) { switch (version) { case MSBuildVersion.Net40x86: return new MSBuild40x86(parameters); case MSBuildVersion.Net40x64: return new MSBuild40x64(parameters); case MSBuildVersion.VS2013: return new MSBuildVS2013(parameters); case MSBuildVersion.VS2015: return new MSBuildVS2015(parameters); case MSBuildVersion.Default: return new MSBuildInPath(parameters); default: throw new ArgumentOutOfRangeException("version"); } }
public void Should_Add_ToolVersion_Argument_If_Specified(MSBuildVersion toolVersion, string expectedToolVersion) { // Given var fixture = new DotNetCoreMSBuildBuilderFixture(); fixture.Settings.ToolVersion = toolVersion; // When var result = fixture.Run(); // Then Assert.Equal($"msbuild /toolsversion:{expectedToolVersion}", result.Args); }
private static Instance GetVs2013To2015Instance(MSBuildPlatform platform, MSBuildVersion version) { var basePath = Path.Combine( EnvironmentInfo.SpecialFolder(SpecialFolders.ProgramFilesX86).NotNull("path1 != null"), $@"MSBuild\{GetVersionFolder(version)}\Bin"); return(new Instance( version, platform, platform == MSBuildPlatform.x64 ? Path.Combine(basePath, "amd64") : basePath)); }
private static Instance GetFromVs2017Instance(MSBuildVersion version, MSBuildPlatform platform, string edition) { var versionDirectoryName = version.ToString().TrimStart("VS"); var basePath = Path.Combine( EnvironmentInfo.SpecialFolder(SpecialFolders.ProgramFilesX86).NotNull("path1 != null"), $@"Microsoft Visual Studio\{versionDirectoryName}\{edition}\MSBuild\{GetVersionFolder(version)}\Bin"); return(new Instance( version, platform, platform == MSBuildPlatform.x64 ? Path.Combine(basePath, "amd64") : basePath)); }
private static DirectoryPath GetMSBuildPath( IFileSystem fileSystem, ICakeEnvironment environment, MSBuildVersion version, MSBuildPlatform buildPlatform, string customVersion, bool allowPreview) { switch (version) { case MSBuildVersion.MSBuild17: return(GetVisualStudio2022Path(fileSystem, environment, buildPlatform, allowPreview)); case MSBuildVersion.MSBuild16: return(GetVisualStudio2019Path(fileSystem, environment, buildPlatform, allowPreview)); case MSBuildVersion.MSBuild15: return(GetVisualStudio2017Path(fileSystem, environment, buildPlatform, allowPreview)); case MSBuildVersion.MSBuild14: return(GetVisualStudioPath(environment, buildPlatform, "14.0")); case MSBuildVersion.MSBuild12: return(GetVisualStudioPath(environment, buildPlatform, "12.0")); case MSBuildVersion.MSBuildCustomVS: return(GetVisualStudioPath(environment, buildPlatform, customVersion)); case MSBuildVersion.MSBuild4: return(GetFrameworkPath(environment, buildPlatform, "v4.0.30319")); case MSBuildVersion.MSBuild35: return(GetFrameworkPath(environment, buildPlatform, "v3.5")); case MSBuildVersion.MSBuild20: return(GetFrameworkPath(environment, buildPlatform, "v2.0.50727")); case MSBuildVersion.MSBuildNETCustom: if (!customVersion.Contains("v")) { customVersion = "v" + customVersion; } return(GetFrameworkPath(environment, buildPlatform, customVersion)); default: return(null); } }
private static DirectoryPath GetMSBuildPath(ICakeEnvironment environment, MSBuildVersion version, PlatformTarget target) { switch (version) { case MSBuildVersion.MSBuild12: return GetVisualStudioPath(environment, target); case MSBuildVersion.MSBuild4: return GetFrameworkPath(environment, target, "v4.0.30319"); case MSBuildVersion.MSBuild35: return GetFrameworkPath(environment, target, "v3.5"); case MSBuildVersion.MSBuild20: return GetFrameworkPath(environment, target, "v2.0.50727"); default: return null; } }
private static string GetVersionFolder(MSBuildVersion version) { switch (version) { case MSBuildVersion.VS2017: return("15.0"); case MSBuildVersion.VS2015: return("14.0"); case MSBuildVersion.VS2013: return("12.0"); default: throw new ArgumentOutOfRangeException(nameof(version), version, message: null); } }
public IMSBuild CreateMSBuild(MSBuildVersion version) { switch (version) { case MSBuildVersion.Net40x86: return(new MSBuild40x86(parameters)); case MSBuildVersion.Net40x64: return(new MSBuild40x64(parameters)); case MSBuildVersion.VS2013: return(new MSBuildVS2013(parameters)); case MSBuildVersion.VS2015: return(new MSBuildVS2015(parameters)); case MSBuildVersion.VS2017: return(new MSBuildVS2017(parameters)); case MSBuildVersion.VS2019: return(new MSBuildVS2019(parameters)); case MSBuildVersion.Default: return(new MSBuildInPath(parameters)); default: throw new ArgumentOutOfRangeException("version"); } }
private static string GetMSBuildPath(MSBuildVersion version, MSBuildPlatform platform) { switch (version) { case MSBuildVersion.MSBuild14: return(GetVisualStudioPath(platform, "14.0")); case MSBuildVersion.MSBuild12: return(GetVisualStudioPath(platform, "12.0")); case MSBuildVersion.MSBuild4: return(GetFrameworkPath(platform, "v4.0.30319")); case MSBuildVersion.MSBuild35: return(GetFrameworkPath(platform, "v3.5")); case MSBuildVersion.MSBuild20: return(GetFrameworkPath(platform, "v2.0.50727")); default: return(null); } }
/// <summary> /// Creates the builder /// </summary> /// <param name="projectGuidManagement">The project-guid mapper to use</param> /// <param name="projectPlatformManagement">Interface for getting default project configuration names</param> /// <param name="supportedSlnProjects">Supported project types</param> /// <param name="projects">The projects to be included to the solution</param> /// <param name="msBuildVersion">MSBuild version to use</param> /// <param name="suiteRoot">Suite's root directory </param> /// <param name="targetDir">The target directory where the sln file should be put</param> /// <param name="slnNameGenerator">Name generator implementation for the sln file </param> /// <param name="inSolutionReferenceBuilderFactory">Interface to create new in-solution reference builder instances</param> /// <param name="solutionItemProviders">List of registered solution item providers</param> /// <param name="projectPathManagement">Project-project path mapping</param> public SlnBuilder(IProjectGuidManagement projectGuidManagement, IProjectPlatformManagement projectPlatformManagement, IEnumerable <ISlnProject> supportedSlnProjects, IEnumerable <Project> projects, MSBuildVersion msBuildVersion, [SuiteRoot] IFileSystemDirectory suiteRoot, [TargetRoot] IFileSystemDirectory targetDir, ISlnNameGenerator slnNameGenerator, IInSolutionReferenceBuilderFactory inSolutionReferenceBuilderFactory, IEnumerable <ISolutionItemProvider> solutionItemProviders, IProjectPathManagement projectPathManagement) { Contract.Requires(projectGuidManagement != null); Contract.Requires(projectPlatformManagement != null); Contract.Requires(projectPathManagement != null); Contract.Requires(supportedSlnProjects != null); Contract.Requires(projects != null); Contract.Requires(targetDir != null); Contract.Requires(suiteRoot != null); Contract.Requires(slnNameGenerator != null); Contract.Requires(inSolutionReferenceBuilderFactory != null); Contract.Requires(solutionItemProviders != null); this.projectGuidManagement = projectGuidManagement; this.supportedSlnProjects = supportedSlnProjects; this.suiteRoot = suiteRoot; this.projects = projects.ToList(); this.msBuildVersion = msBuildVersion; this.targetDir = targetDir; this.slnNameGenerator = slnNameGenerator; this.solutionItemProviders = solutionItemProviders; this.projectPlatformManagement = projectPlatformManagement; }
private static DirectoryPath GetMSBuildPath(ICakeEnvironment environment, MSBuildVersion version, MSBuildPlatform buildPlatform) { switch (version) { case MSBuildVersion.MSBuild14: return(GetVisualStudioPath(environment, buildPlatform, "14.0")); case MSBuildVersion.MSBuild12: return(GetVisualStudioPath(environment, buildPlatform, "12.0")); case MSBuildVersion.MSBuild4: return(GetFrameworkPath(environment, buildPlatform, "v4.0.30319")); case MSBuildVersion.MSBuild35: return(GetFrameworkPath(environment, buildPlatform, "v3.5")); case MSBuildVersion.MSBuild20: return(GetFrameworkPath(environment, buildPlatform, "v2.0.50727")); default: return(null); } }
/// <summary> /// Initializes the solution file generator /// </summary> /// <param name="projectGuidManagement">Project guid mapping to be used</param> /// <param name="projectPlatformManagement">For getting project's default platform name</param> /// <param name="supportedSlnProjects">All the supported SLN project implementations</param> /// <param name="projects">The set of projects to be added to the solution</param> /// <param name="msBuildVersion">Current MSBuild version</param> /// <param name="output">Text writer to write the solution file</param> /// <param name="suiteRoot">Suite's root directory </param> /// <param name="slnDir">Directory where the sln is being generated </param> /// <param name="getProjectSolutionReferences">Function which returns all the referenced projects which are in the same solution</param> /// <param name="solutionItemProviders">List of registered solution item providers</param> /// <param name="slnName">Solution's unique name</param> public SlnGenerator(IProjectGuidManagement projectGuidManagement, IProjectPlatformManagement projectPlatformManagement, IEnumerable <ISlnProject> supportedSlnProjects, IEnumerable <Project> projects, MSBuildVersion msBuildVersion, TextWriter output, IFileSystemDirectory suiteRoot, IFileSystemDirectory slnDir, Func <Project, IEnumerable <Project> > getProjectSolutionReferences, IEnumerable <ISolutionItemProvider> solutionItemProviders, string slnName) { Contract.Requires(projectGuidManagement != null); Contract.Requires(projectPlatformManagement != null); Contract.Requires(projects != null); Contract.Requires(output != null); Contract.Requires(suiteRoot != null); Contract.Requires(slnDir != null); Contract.Requires(getProjectSolutionReferences != null); Contract.Requires(supportedSlnProjects != null); Contract.Requires(solutionItemProviders != null); this.projectGuidManagement = projectGuidManagement; this.projectPlatformManagement = projectPlatformManagement; this.projects = projects.ToList(); this.output = output; this.suiteRoot = suiteRoot; this.slnDir = slnDir; this.getProjectSolutionReferences = getProjectSolutionReferences; this.solutionItemProviders = solutionItemProviders; this.slnName = slnName; this.supportedSlnProjects = supportedSlnProjects; this.msBuildVersion = msBuildVersion; }
/// <summary> /// Initializes the solution file generator /// </summary> /// <param name="projectGuidManagement">Project guid mapping to be used</param> /// <param name="projectPlatformManagement">For getting project's default platform name</param> /// <param name="supportedSlnProjects">All the supported SLN project implementations</param> /// <param name="projects">The set of projects to be added to the solution</param> /// <param name="msBuildVersion">Current MSBuild version</param> /// <param name="output">Text writer to write the solution file</param> /// <param name="suiteRoot">Suite's root directory </param> /// <param name="slnDir">Directory where the sln is being generated </param> /// <param name="getProjectSolutionReferences">Function which returns all the referenced projects which are in the same solution</param> /// <param name="solutionItemProviders">List of registered solution item providers</param> /// <param name="slnName">Solution's unique name</param> public SlnGenerator(IProjectGuidManagement projectGuidManagement, IProjectPlatformManagement projectPlatformManagement, IEnumerable<ISlnProject> supportedSlnProjects, IEnumerable<Project> projects, MSBuildVersion msBuildVersion, TextWriter output, IFileSystemDirectory suiteRoot, IFileSystemDirectory slnDir, Func<Project, IEnumerable<Project>> getProjectSolutionReferences, IEnumerable<ISolutionItemProvider> solutionItemProviders, string slnName) { Contract.Requires(projectGuidManagement != null); Contract.Requires(projectPlatformManagement != null); Contract.Requires(projects != null); Contract.Requires(output != null); Contract.Requires(suiteRoot != null); Contract.Requires(slnDir != null); Contract.Requires(getProjectSolutionReferences != null); Contract.Requires(supportedSlnProjects != null); Contract.Requires(solutionItemProviders != null); this.projectGuidManagement = projectGuidManagement; this.projectPlatformManagement = projectPlatformManagement; this.projects = projects.ToList(); this.output = output; this.suiteRoot = suiteRoot; this.slnDir = slnDir; this.getProjectSolutionReferences = getProjectSolutionReferences; this.solutionItemProviders = solutionItemProviders; this.slnName = slnName; this.supportedSlnProjects = supportedSlnProjects; this.msBuildVersion = msBuildVersion; }
public SlnBuilder CreateSlnBuilder(IEnumerable <Project> projects, MSBuildVersion msBuildVersion) { return(store.Add(baseImpl.CreateSlnBuilder(projects, msBuildVersion))); }
public override int GetHashCode() { return(MSBuildVersion.GetHashCode()); }
public SlnBuilder CreateSlnBuilder(IEnumerable<Project> projects, MSBuildVersion msBuildVersion) { return store.Add(baseImpl.CreateSlnBuilder(projects, msBuildVersion)); }
public IMSBuild CreateMSBuild(MSBuildVersion version) { return new XBuild(parameters); }
/// <summary> /// Sets the version of the Toolset to use to build the project. /// </summary> /// <param name="settings">The settings.</param> /// <param name="version">The version.</param> /// <returns>The same <see cref="DotNetCoreMSBuildSettings"/> instance so that multiple calls can be chained.</returns> public static DotNetCoreMSBuildSettings UseToolVersion(this DotNetCoreMSBuildSettings settings, MSBuildVersion version) { return((DotNetCoreMSBuildSettings)DotNet.MSBuild.DotNetMSBuildSettingsExtensions.UseToolVersion(settings, version)); }
/// <summary> /// Sets the version of the Toolset to use to build the project. /// </summary> /// <param name="settings">The settings.</param> /// <param name="version">The version.</param> /// <returns>The same <see cref="DotNetMSBuildSettings"/> instance so that multiple calls can be chained.</returns> public static DotNetMSBuildSettings UseToolVersion(this DotNetMSBuildSettings settings, MSBuildVersion version) { EnsureSettings(settings); settings.ToolVersion = version; return(settings); }
public IMSBuild CreateMSBuild(MSBuildVersion version) { return(new XBuild(parameters)); }
public MSBuildRunner CreateMSBuildRunner(SlnBuilder slnBuilder, TargetRelativePath slnPath, MSBuildVersion version) { return(store.Add(baseImpl.CreateMSBuildRunner(slnBuilder, slnPath, version))); }
public Instance(MSBuildVersion version, MSBuildPlatform platform, string directory) { Platform = platform; Version = version; ToolPath = Path.Combine(directory, "msbuild.exe"); }
public MSBuildRunner CreateMSBuildRunner(SlnBuilder slnBuilder, TargetRelativePath slnPath, MSBuildVersion version) { return store.Add(baseImpl.CreateMSBuildRunner(slnBuilder, slnPath, version)); }
public MSBuildParameters() { Version = MSBuildVersion.Net40x86; }