Skip to content

Commit

Permalink
Roslyn non-source-only build fixes (#72360)
Browse files Browse the repository at this point in the history
* Roslyn non-source-only build fixes
These changes make it possible to build roslyn in non-source-only modes in the VMR:
- Remove some vertical build (non-source-only) exclusions that were added during the PoC phase of the VMR
- When packing the language server nuget package, Pack only the rid that the current vertical is building.
- Mark a couple benchmark projects as IsTestProject. Tests are excluded by default when building the VMR
- Mark a couple of test utility projects as test utility projects. When not building tests, these projects are excluded from the build.

* Improve comments

* Use ExcludeFromDotNetBuild instead of IsTestProject for benchmark projects

* Add more comments

* Update src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Microsoft.CodeAnalysis.LanguageServer.csproj

Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>

---------

Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
  • Loading branch information
mmitche and ViktorHofer committed Mar 5, 2024
1 parent 0d6e0ba commit cc94c18
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<TargetFramework>net472</TargetFramework>
<DefineConstants>$(DefineConstants),CODE_STYLE</DefineConstants>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\..\..\Features\DiagnosticsTestUtilities\CodeActionsLegacy\AbstractCodeActionOrUserDiagnosticTest_NoEditor.cs" Link="TestFramework\AbstractCodeActionOrUserDiagnosticTest_NoEditor.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<TargetFramework>net472</TargetFramework>
<DefineConstants>$(DefineConstants),CODE_STYLE</DefineConstants>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\..\..\Features\DiagnosticsTestUtilities\CodeActions\AnalyzerProperty.cs" Link="AnalyzerProperty.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@
<PublishDir Condition="'$(RuntimeIdentifier)' != ''">$(ArtifactsDir)/LanguageServer/$(Configuration)/$(TargetFramework)/$(RuntimeIdentifier)</PublishDir>
<PublishDir Condition="'$(RuntimeIdentifier)' == ''">$(ArtifactsDir)/LanguageServer/$(Configuration)/$(TargetFramework)/neutral</PublishDir>

<!-- List of runtime identifiers that we want to publish an executable for -->
<RuntimeIdentifiers>win-x64;win-x86;win-arm64;linux-x64;linux-arm64;linux-musl-x64;linux-musl-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<!-- List of runtime identifiers that we want to publish an executable for. -->
<!-- When building a VMR vertical, we don't need to pack everything. Just pack the passed in TargetRid.
TargetRid is provided to roslyn via the build arguments passed in the VMR orchestrator's repo project.
https://github.com/dotnet/dotnet/blob/main/repo-projects/roslyn.proj. For definitions of the TargetRid
and other common properties, see https://github.com/dotnet/arcade/blob/main/Documentation/UnifiedBuild/Unified-Build-Controls.md -->
<RuntimeIdentifiers Condition="'$(TargetRid)' != ''">$(TargetRid)</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(TargetRid)' == ''">win-x64;win-x86;win-arm64;linux-x64;linux-arm64;linux-musl-x64;linux-musl-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<!-- Publish ready to run executables when we're publishing platform specific executables. -->
<PublishReadyToRun Condition="'$(RuntimeIdentifier)' != '' AND '$(Configuration)' == 'Release' ">true</PublishReadyToRun>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
"The assembly '...' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project."
-->
<NoWarn>$(NoWarn);NU5100</NoWarn>

<!-- Work around missing project dependencies. VS features not needed at this time:
https://github.com/dotnet/source-build/issues/3981. -->
<ExcludeFromVerticalBuild>true</ExcludeFromVerticalBuild>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@
</Copy>
</Target>

<!-- TODO: https://github.com/dotnet/source-build/issues/3981 for where this should be excluded in vertical modes. -->
<Target Name="_GenerateSwrFile"
AfterTargets="Build"
BeforeTargets="SwixBuild"
DependsOnTargets="_SetSwrFilePath;InitializeDesktopCompilerArtifacts;_PrepareDesktopCompilerArtifactsForOptimization;ApplyOptimizations"
Outputs="$(_SwrFilePath)"
Condition="'$(DotNetBuildFromSource)' != 'true' and '$(DotNetBuildVertical)' != 'true'">
Condition="'$(DotNetBuildFromSource)' != 'true'">

<ItemGroup>
<_File Include="@(DesktopCompilerArtifact)">
Expand Down
3 changes: 0 additions & 3 deletions src/Setup/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
<PropertyGroup>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
<!-- TODO: https://github.com/dotnet/source-build/issues/3981
Remove if necessary. -->
<ExcludeFromVerticalBuild>true</ExcludeFromVerticalBuild>
</PropertyGroup>
</Project>
3 changes: 0 additions & 3 deletions src/Tools/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
<PropertyGroup>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
<!-- TODO: https://github.com/dotnet/source-build/issues/3981
Remove if necessary. -->
<ExcludeFromVerticalBuild>true</ExcludeFromVerticalBuild>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
</PackageDescription>
<!-- Referenced by dotnet/aspnetcore and included in SDK. Required for source build/vertical build. -->
<ExcludeFromSourceBuild>false</ExcludeFromSourceBuild>
<ExcludeFromVerticalBuild>false</ExcludeFromVerticalBuild>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
A supporting package for Razor:
https://github.com/dotnet/razor
</PackageDescription>
<ExcludeFromVerticalBuild>false</ExcludeFromVerticalBuild>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions src/Tools/IdeBenchmarks/IdeBenchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
<!-- Xunit analyzer doesn't recognize benchmark attributes -->
<NoWarn>$(NoWarn),xUnit1013</NoWarn>
<UseWpf>true</UseWpf>
<!-- This project is not a test project in context of how this repo views test projects.
Marking it as such will change TFMs, bring in additional targets, and generally fail to build.
However, it is a 'test' type project and depends on other test utility projects that may be built in
every build invocation. For intance, when building officially in the VMR, test and test utility projects are excluded.
So, when test projects are excluded, exclude this benchmark project.
See https://github.com/dotnet/arcade/blob/main/Documentation/UnifiedBuild/Unified-Build-Controls.md for information
on controls. -->
<ExcludeFromDotNetBuild Condition="'$(DotNetBuildTests)' != 'true'">true</ExcludeFromDotNetBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" />
Expand Down
8 changes: 8 additions & 0 deletions src/Tools/IdeCoreBenchmarks/IdeCoreBenchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
<LangVersion>11</LangVersion>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<NoWarn>$(NoWarn);NETSDK1206</NoWarn>
<!-- This project is not a test project in context of how this repo views test projects.
Marking it as such will change TFMs, bring in additional targets, and generally fail to build.
However, it is a 'test' type project and depends on other test utility projects that may be built in
every build invocation. For intance, when building officially in the VMR, test and test utility projects are excluded.
So, when test projects are excluded, exclude this benchmark project.
See https://github.com/dotnet/arcade/blob/main/Documentation/UnifiedBuild/Unified-Build-Controls.md for information
on controls. -->
<ExcludeFromDotNetBuild Condition="'$(DotNetBuildTests)' != 'true'">true</ExcludeFromDotNetBuild>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<RuntimeIdentifiers>$(RoslynPortableRuntimeIdentifiers)</RuntimeIdentifiers>
<IsShipping>false</IsShipping>
<ExcludeFromSourceBuild>false</ExcludeFromSourceBuild>
<ExcludeFromVerticalBuild>false</ExcludeFromVerticalBuild>
</PropertyGroup>
<ItemGroup>
<!-- Make sure to reference the same version of Microsoft.CodeAnalysis.Analyzers as the rest of the build -->
Expand Down
3 changes: 0 additions & 3 deletions src/VisualStudio/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
<PropertyGroup>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
<!-- TODO: https://github.com/dotnet/source-build/issues/3981
Remove if necessary. -->
<ExcludeFromVerticalBuild>true</ExcludeFromVerticalBuild>
</PropertyGroup>
</Project>

0 comments on commit cc94c18

Please sign in to comment.