-
-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d72ad9d
commit 79dd046
Showing
6 changed files
with
109 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using Nuke.Common.Tooling; | ||
using Nuke.Common.ProjectModel; | ||
|
||
partial class Build | ||
{ | ||
[PackageExecutable( | ||
packageId: "Microsoft.VisualStudio.SlnGen.Tool", | ||
packageExecutable: "slngen.exe", | ||
// Must be set for tools shipping multiple versions | ||
Framework = "net8.0")] | ||
readonly Tool SlnGen; | ||
|
||
IReadOnlyCollection<Output> DotNetBuildSonarSolution( | ||
string solutionOutputFile, | ||
IEnumerable<string> directories = null, | ||
Func<string, bool> include = null) | ||
{ | ||
var projects = Helpers.GetAllProjects(SourceDirectory, directories, include); | ||
var result = CreateSolution(solutionOutputFile, projects); | ||
return result; | ||
} | ||
|
||
IReadOnlyCollection<Output> DotNetBuildTestSolution( | ||
string solutionOutputFile, | ||
IEnumerable<Project> projects) | ||
{ | ||
var projectPaths = projects.Select(p => (string) p.Path); | ||
var result = CreateSolution(solutionOutputFile, projectPaths); | ||
return result; | ||
} | ||
|
||
IReadOnlyCollection<Output> CreateSolution( | ||
string solutionOutputFile, | ||
IEnumerable<string> projectAbsolutePaths) | ||
{ | ||
if (File.Exists(solutionOutputFile)) | ||
{ | ||
return Array.Empty<Output>(); | ||
} | ||
|
||
var solutionDirectory = Path.GetDirectoryName(solutionOutputFile)!; | ||
var workingDirectory = solutionDirectory; | ||
|
||
var arguments = new Arguments(); | ||
|
||
foreach (var projectAbsolutePath in projectAbsolutePaths) | ||
{ | ||
var projectRelativePath = Path.GetRelativePath(workingDirectory, projectAbsolutePath); | ||
arguments.Add($"{projectRelativePath}"); | ||
} | ||
|
||
// https://microsoft.github.io/slngen/ | ||
arguments.Add("--solutionfile {value}", solutionOutputFile); | ||
arguments.Add("--launch {value}", "false"); | ||
arguments.Add("--verbosity {value}", "minimal"); | ||
arguments.Add("--folders {value}", "true"); | ||
|
||
var result = SlnGen( | ||
arguments: arguments.RenderForExecution(), | ||
workingDirectory: workingDirectory); | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters