MSBuild( ProduceRepository repository, VisualStudioSolution sln, IDictionary <string, string> properties, IEnumerable <string> targets) { Guard.NotNull(repository, nameof(repository)); Guard.NotNull(sln, nameof(sln)); Guard.NotNull(properties, nameof(properties)); Guard.NotNull(targets, nameof(targets)); var args = new List <string>() { "/nr:false", "/v:m", }; args.AddRange(properties.Select(p => $"/p:{p.Key}=\"{p.Value}\"")); args.AddRange(targets.Select(t => $"/t:{t}")); if (ProcessExtensions.ExecuteAny(true, true, repository.Path, "msbuild", args.ToArray()) != 0) { throw new UserException("Failed"); } }
DotnetModule() { CanBuildNetFramework = false; BuildNetFrameworkUsingMSBuild = false; // // On Windows we can always build for .NET Frameworks // if (EnvironmentExtensions.IsWindows) { CanBuildNetFramework = true; } // // On UNIX we can build for .NET Frameworks using Mono, which we assume is available if a standalone `msbuild` is // present // else { if (ProcessExtensions.ExecuteAny(false, false, null, "msbuild", "/version") == 0) { CanBuildNetFramework = true; BuildNetFrameworkUsingMSBuild = true; } } }
Update(ProduceRepository repository) { using (LogicalOperation.Start("Updating NuGit dependencies")) if (ProcessExtensions.ExecuteAny(true, true, repository.Path, "nugit", "update") != 0) { throw new UserException("nugit failed"); } }
Dotnet(ProduceRepository repository, params string[] args) { Guard.NotNull(repository, nameof(repository)); if (ProcessExtensions.ExecuteAny(true, true, repository.Path, "dotnet", args.ToArray()) != 0) { throw new UserException("Failed"); } }
protected override bool OnApply() { if (slnNames.Count > 1) { var incorrectSlns = slnNames .Where(sln => sln != correctSlnName) .ToList(); foreach (var sln in incorrectSlns) { using (LogicalOperation.Start($"Deleting {sln}")) { var path = Path.Combine(Context.Path, sln); File.Delete(path); slnNames.Remove(sln); } } } if (slnNames.Count == 0) { using (LogicalOperation.Start($"Creating {correctSlnName}")) { var exitCode = ProcessExtensions.ExecuteAny( true, true, Context.Path, "dotnet", "new", "sln", "--name", correctSlnName); if (exitCode != 0) { Trace.TraceError("dotnet new sln failed"); return(false); } } } return(true); }