Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the build compatible with .NET 9 SDK #2840

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/BuildAndTest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function Invoke-DotNetBuild($solutionFileRelativePath) {
Write-Information "Building $solutionFileRelativePath..."

$solutionFilePath = Join-Path $SourceRoot $solutionFileRelativePath
& dotnet build $solutionFilePath --configuration $Configuration --verbosity $BuildVerbosity --no-incremental -bl -p:WarningsAsErrors="MSB3277" /p:EnforceCodeStyleInBuild=true
& dotnet build $solutionFilePath --configuration $Configuration --verbosity $BuildVerbosity --no-incremental -bl /p:EnforceCodeStyleInBuild=true

if ($LASTEXITCODE -ne 0) {
Exit-WithFailureMessage $ScriptName "Build of $solutionFilePath failed."
Expand Down
2 changes: 1 addition & 1 deletion scripts/BuildMultitoolForNpm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $npmBuildFolder = "$BuildRoot\Publish\npm"
if (-not $SkipBuild) {
Write-Information "Building Sarif.Multitool for Windows, Linux, and MacOS..."
foreach ($runtime in "win-x64", "linux-x64", "osx-x64") {
dotnet publish $SourceRoot\$project\$project.csproj -c $Configuration -f netcoreapp3.1 -r $runtime
dotnet publish $SourceRoot\$project\$project.csproj -c $Configuration -f netcoreapp3.1 -r $runtime --self-contained
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a .NET 9 SDK warning that tells us that --self-contained will no longer be the default as before when runtime identifier is specified.

}

Write-Information "Merging binaries [$projectBinDirectory] and NPM configuration [$npmSourceFolder]..."
Expand Down
3 changes: 3 additions & 0 deletions src/Directory.Solution.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="build.warnings_as_errors.props" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is maddeningly difficult to get the same behavior for building .sln as .csproj for these settings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed!

</Project>
19 changes: 5 additions & 14 deletions src/build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<LangVersion>8.0</LangVersion>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this was already reset to latest below this before.

<LangVersion>latest</LangVersion>
<AnalysisMode>Default</AnalysisMode>
<AnalysisLevel>latest</AnalysisLevel>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Expand All @@ -18,10 +21,6 @@

<!-- The stable version of the SARIF specification. -->
<StableSarifVersion>2.1.0</StableSarifVersion>

<AnalysisLevel>latest</AnalysisLevel>
<LangVersion>latest</LangVersion>

</PropertyGroup>

<PropertyGroup Label="Build">
Expand All @@ -40,10 +39,6 @@
<PackageOutputPath>$(MsBuildThisFileDirectory)..\bld\Publish\Nuget\$(Configuration)\</PackageOutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<!-- These can change externally, breaking our build. -->
<WarningsNotAsErrors>NU1901;NU1902;NU1903;NU1904</WarningsNotAsErrors>
<HighEntropyVA>true</HighEntropyVA>
<!-- The line causes the assemblies in a project's referenced NuGet packages to be
copied to the output directory. If we omit it from a test project, the tests
Expand Down Expand Up @@ -118,9 +113,5 @@
<SourceRoot Include="$(MSBuildThisFileDirectory)/" />
</ItemGroup>

<PropertyGroup>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<AnalysisMode>Default</AnalysisMode>
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>
<Import Project="./build.warnings_as_errors.props" />
</Project>
27 changes: 27 additions & 0 deletions src/build.warnings_as_errors.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project>
<!--
NOTE: We only turn on warnings-as-errors in Release because it hurts
iteration time in the IDE to error out while the code is still
work-in-progress.
-->
<PropertyGroup Label="WarningsAsErrors" Condition="'$(Configuration)' == 'Release'">
<!-- Treat compiler warnings as errors. -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<!-- Treat all build warnings as errors -->
<MSBuildTreatWarningsAsErrors>$(TreatWarningsAsErrors)</MSBuildTreatWarningsAsErrors>

<!--
NU190X are security vulnerability warnings and can trigger without code
changes. Don't let them break the build.
-->
<WarningsNotAsErrors>$(WarningsNotAsErrors);NU1901;NU1902;NU1903;NU1904</WarningsNotAsErrors>
<MSBuildWarningsNotAsErrors>$(WarningsNotAsErrors)</MSBuildWarningsNotAsErrors>

<!--
We are not yet clean on new analysis introduced with .NET 9 SDK so lower
the analysis level when treating warnings as errors in Release.
-->
<AnalysisLevel>8</AnalysisLevel>
</PropertyGroup>
</Project>
Loading