/// <summary> /// Sets the tool version. /// </summary> /// <param name="settings">The settings.</param> /// <param name="version">The version.</param> /// <returns>The same <see cref="MSBuildSettings"/> instance so that multiple calls can be chained.</returns> public static MSBuildSettings UseToolVersion(this MSBuildSettings settings, MSBuildToolVersion version) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } settings.ToolVersion = version; return(settings); }
public static FilePath GetMSBuildPath(ICakeEnvironment environment, MSBuildToolVersion version, PlatformTarget target) { // Get the bin path for MSBuild. var binPath = GetMSBuildPath(environment, (MSBuildVersion)version, target); if (binPath == null) { throw new CakeException("Could not resolve MSBuild."); } // Get the MSBuild path. return(binPath.CombineWithFilePath("MSBuild.exe")); }
public void Should_Get_Correct_Path_To_MSBuild_Version_35(MSBuildToolVersion version, PlatformTarget target, bool is64BitOperativeSystem, string expected) { // Given var fixture = new MSBuildRunnerFixture(is64BitOperativeSystem, true); fixture.Settings.ToolVersion = version; fixture.Settings.PlatformTarget = target; // When fixture.Run(); // Then fixture.AssertReceivedFilePath(expected); }
public void Should_Get_Correct_Path_To_MSBuild_Version_35(MSBuildToolVersion version, PlatformTarget target, bool is64BitOperativeSystem, string expected) { // Given var fixture = new MSBuildRunnerFixture(is64BitOperativeSystem); var runner = fixture.CreateRunner(); // When runner.Run(new MSBuildSettings("./src/Solution.sln") { ToolVersion = version, PlatformTarget = target }); // Then fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>( p => p.FileName == expected)); }
public static string GetMSBuildPath(MSBuildPlatform platform = MSBuildPlatform.Automatic, MSBuildToolVersion version = MSBuildToolVersion.Default) { var binPath = version == MSBuildToolVersion.Default ? GetHighestAvailableMSBuildVersion(platform) : GetMSBuildPath((MSBuildVersion)version, platform); if (binPath == null) { throw new Exception("Could not resolve MSBuild."); } // Get the MSBuild path. return(Path.Combine(binPath, "msbuild.exe")); }
public static string GetBuildAssemblyPath(string assemblyName, MSBuildPlatform platform = MSBuildPlatform.Automatic, MSBuildToolVersion version = MSBuildToolVersion.Default, Action <string> logCallback = null) { logCallback = logCallback ?? Console.WriteLine; var binPath = version == MSBuildToolVersion.Default ? GetHighestAvailableMSBuildVersion(platform) : GetMSBuildPath((MSBuildVersion)version, platform); // Get the MSBuild path. if (binPath == null || !File.Exists(Path.Combine(binPath, $"{assemblyName}.dll"))) { logCallback?.Invoke($"Could not locate assembly {assemblyName}"); return(null); } else { logCallback?.Invoke($"Found {assemblyName} at {binPath}"); return(Path.Combine(binPath, $"{assemblyName}.dll")); } }
public static FilePath GetMSBuildPath(IFileSystem fileSystem, ICakeEnvironment environment, MSBuildToolVersion version, MSBuildPlatform buildPlatform) { var binPath = version == MSBuildToolVersion.Default ? GetHighestAvailableMSBuildVersion(fileSystem, environment, buildPlatform) : GetMSBuildPath(environment, (MSBuildVersion)version, buildPlatform); if (binPath == null) { throw new CakeException("Could not resolve MSBuild."); } // Get the MSBuild path. return(binPath.CombineWithFilePath("MSBuild.exe")); }
public static FilePath GetMSBuildPath(IFileSystem fileSystem, ICakeEnvironment environment, MSBuildToolVersion version, MSBuildPlatform buildPlatform) { if (environment.Platform.Family == PlatformFamily.OSX) { var macMSBuildPath = new FilePath("/Library/Frameworks/Mono.framework/Versions/Current/Commands/msbuild"); if (fileSystem.Exist(macMSBuildPath)) { return(macMSBuildPath); } var brewMSBuildPath = new FilePath("/usr/local/bin/msbuild"); if (fileSystem.Exist(brewMSBuildPath)) { return(brewMSBuildPath); } throw new CakeException("Could not resolve MSBuild."); } else if (environment.Platform.Family == PlatformFamily.Linux) { var linuxMSBuildPath = new FilePath("/usr/bin/msbuild"); if (fileSystem.Exist(linuxMSBuildPath)) { return(linuxMSBuildPath); } throw new CakeException("Could not resolve MSBuild."); } var binPath = version == MSBuildToolVersion.Default ? GetHighestAvailableMSBuildVersion(fileSystem, environment, buildPlatform) : GetMSBuildPath(fileSystem, environment, (MSBuildVersion)version, buildPlatform); if (binPath == null) { throw new CakeException("Could not resolve MSBuild."); } // Get the MSBuild path. return(binPath.CombineWithFilePath("MSBuild.exe")); }