Skip to content

Commit c8124cf

Browse files
committed
Consolidate build and NativeAOT publish
1 parent 81ce4f6 commit c8124cf

File tree

11 files changed

+76
-14
lines changed

11 files changed

+76
-14
lines changed

Directory.Build.props

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@
4141
<LangVersion Condition="'$(MSBuildProjectExtension)'=='.vbproj'">16.9</LangVersion>
4242
</PropertyGroup>
4343

44+
<PropertyGroup>
45+
<RidOsPrefix Condition="$([MSBuild]::IsOsPlatform('Windows'))">win</RidOsPrefix>
46+
<RidOsPrefix Condition="$([MSBuild]::IsOsPlatform('Linux'))">linux</RidOsPrefix>
47+
<RidOsPrefix Condition="$([MSBuild]::IsOsPlatform('OSX'))">osx</RidOsPrefix>
48+
49+
<RidOsArchitecture Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'x64'">x64</RidOsArchitecture>
50+
<RidOsArchitecture Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'ARM64'">arm64</RidOsArchitecture>
51+
52+
<DefaultRuntimeIdentifier>$(RidOsPrefix)-$(RidOsArchitecture)</DefaultRuntimeIdentifier>
53+
<!-- <AvailableRuntimeIdentifiers>$(RidOsPrefix)-arm64;$(RidOsPrefix)-x64</AvailableRuntimeIdentifiers> -->
54+
<AvailableRuntimeIdentifiers>$(DefaultRuntimeIdentifier)</AvailableRuntimeIdentifiers>
55+
</PropertyGroup>
56+
4457
<ItemGroup>
4558
<None Include="$(RepoRootPath)obj/NOTICE" Pack="true" PackagePath="" Visible="false" Condition=" Exists('$(RepoRootPath)obj/NOTICE') " />
4659
</ItemGroup>

Directory.Build.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
<!-- Avoid compile error about missing namespace when combining ImplicitUsings with .NET Framework target frameworks. -->
55
<Using Remove="System.Net.Http" Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'" />
66
</ItemGroup>
7+
8+
<Import Project="Directory.Traversal.targets" Condition="'$(IsTraversal)'=='true'" />
79
</Project>

Directory.Traversal.targets

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project>
2+
<PropertyGroup>
3+
<PackInParallel>true</PackInParallel>
4+
5+
<TestX64Binaries>false</TestX64Binaries>
6+
<TestArm64Binaries>false</TestArm64Binaries>
7+
<TestX64Binaries Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'x64'">true</TestX64Binaries>
8+
<TestArm64Binaries Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'ARM64'">true</TestArm64Binaries>
9+
</PropertyGroup>
10+
<ItemGroup>
11+
<!-- <ProjectReference Include="@(MultiRIDProjectReference)" AdditionalProperties="RuntimeIdentifier=$(RidOsPrefix)-x64" Test="$(TestX64Binaries)" />
12+
<ProjectReference Include="@(MultiRIDProjectReference)" AdditionalProperties="RuntimeIdentifier=$(RidOsPrefix)-arm64" Test="$(TestArm64Binaries)" /> -->
13+
<ProjectReference Include="@(MultiRIDProjectReference)" AdditionalProperties="RuntimeIdentifier=$(DefaultRuntimeIdentifier);TargetFramework=%(TargetFramework)" Test="true" />
14+
</ItemGroup>
15+
</Project>

Microsoft.VisualStudio.Threading.slnx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@
1111
<File Path="Directory.Build.props" />
1212
<File Path="Directory.Build.targets" />
1313
<File Path="Directory.Packages.props" />
14+
<File Path="Directory.Traversal.targets" />
1415
<File Path="global.json" />
1516
<File Path="nuget.config" />
1617
<File Path="stylecop.json" />
1718
<File Path="version.json" />
1819
</Folder>
20+
<Folder Name="/Solution Items/tools/">
21+
<File Path="tools/dirs.proj" />
22+
</Folder>
1923
<Folder Name="/src/">
2024
<File Path="src/.editorconfig" />
2125
<File Path="src/AssemblyInfo.cs" />
2226
<File Path="src/Directory.Build.props" />
2327
<File Path="src/Directory.Build.targets" />
28+
<File Path="src/dirs.proj" />
2429
<Project Path="src/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes.csproj" />
2530
<Project Path="src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/Microsoft.VisualStudio.Threading.Analyzers.CSharp.csproj" />
2631
<Project Path="src/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic/Microsoft.VisualStudio.Threading.Analyzers.VisualBasic.csproj" />
@@ -33,8 +38,10 @@
3338
</Folder>
3439
<Folder Name="/test/">
3540
<File Path="test/.editorconfig" />
41+
<File Path="test/AOT.props" />
3642
<File Path="test/Directory.Build.props" />
3743
<File Path="test/Directory.Build.targets" />
44+
<File Path="test/dirs.proj" />
3845
<Project Path="samples/samples.csproj" />
3946
<Project Path="test/IsolatedTestHost/IsolatedTestHost.csproj" />
4047
<Project Path="test/Microsoft.VisualStudio.Threading.Analyzers.Tests/Microsoft.VisualStudio.Threading.Analyzers.Tests.csproj" />

azure-pipelines/dotnet.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,14 @@ parameters:
1010

1111
steps:
1212

13-
- script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) -warnAsError -warnNotAsError:NU1901,NU1902,NU1903,NU1904,LOCTASK002 /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog"
13+
- script: dotnet build tools/dirs.proj -t:build,pack,publish --no-restore -c $(BuildConfiguration) -warnAsError -warnNotAsError:NU1901,NU1902,NU1903,NU1904,LOCTASK002 /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog"
1414
displayName: 🛠 dotnet build
1515

1616
- ${{ if not(parameters.IsOptProf) }}:
1717
- powershell: tools/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults
1818
displayName: 🧪 dotnet test
1919
condition: and(succeeded(), ${{ parameters.RunTests }})
2020

21-
- powershell: |
22-
dotnet publish -f net9.0 -c Release -r ${{ parameters.osRID }}-x64 -warnaserror
23-
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
24-
if (!($IsMacOS -or $IsLinux)) {
25-
dotnet publish -f net9.0-windows -c Release -r ${{ parameters.osRID }}-x64 -warnaserror
26-
}
27-
displayName: 🧪 NativeAOT test
28-
workingDirectory: test/NativeAOTCompatibility
29-
3021
- ${{ if parameters.IsOptProf }}:
3122
- script: dotnet pack src\VSInsertionMetadata -c $(BuildConfiguration) -warnaserror /bl:"$(Build.ArtifactStagingDirectory)/build_logs/VSInsertion-Pack.binlog"
3223
displayName: 🔧 dotnet pack VSInsertionMetadata

global.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
},
77
"msbuild-sdks": {
88
"MSBuild.Sdk.Extras": "3.0.44",
9-
"Microsoft.Build.NoTargets": "3.7.56"
9+
"Microsoft.Build.NoTargets": "3.7.56",
10+
"Microsoft.Build.Traversal": "4.1.82"
1011
}
1112
}

src/dirs.proj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project Sdk="Microsoft.Build.Traversal">
2+
<ItemGroup>
3+
<ProjectReference Include="**\*.csproj" Publish="false" />
4+
</ItemGroup>
5+
</Project>

test/AOT.props

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project>
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<SelfContained>true</SelfContained>
5+
<PublishAot>true</PublishAot>
6+
<InvariantGlobalization>true</InvariantGlobalization>
7+
<RuntimeIdentifiers>$(AvailableRuntimeIdentifiers)</RuntimeIdentifiers>
8+
<RuntimeIdentifier>$(DefaultRuntimeIdentifier)</RuntimeIdentifier>
9+
</PropertyGroup>
10+
<ItemDefinitionGroup>
11+
<ProjectReference>
12+
<!-- Suppress spreading the RID being built here to RID-neutral projects. -->
13+
<GlobalPropertiesToRemove>RuntimeIdentifier</GlobalPropertiesToRemove>
14+
</ProjectReference>
15+
</ItemDefinitionGroup>
16+
</Project>

test/NativeAOTCompatibility/NativeAOTCompatibility.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
2+
<Import Project="..\AOT.props" />
33
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
54
<TargetFrameworks>net9.0</TargetFrameworks>
6-
<PublishAot>true</PublishAot>
75
<IsTestProject>false</IsTestProject>
86
</PropertyGroup>
97
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">

test/dirs.proj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.Build.Traversal">
2+
<ItemGroup>
3+
<ProjectReference Include="**\*.csproj" Exclude="NativeAOTCompatibility\**" Publish="false" />
4+
5+
<MultiRIDProjectReference Include="NativeAOTCompatibility\NativeAOTCompatibility.csproj" TargetFramework="net9.0" />
6+
<MultiRIDProjectReference Include="NativeAOTCompatibility\NativeAOTCompatibility.csproj" TargetFramework="net9.0-windows" Condition="$([MSBuild]::IsOSPlatform('Windows'))" />
7+
</ItemGroup>
8+
</Project>

0 commit comments

Comments
 (0)