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

Upstream changes from Vertical Build PoC #71666

Merged
merged 17 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
5 changes: 4 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,11 @@ stages:
arguments: -test -configuration Release
condition: or(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['compilerChange'], 'true'))

- script: $(Build.SourcesDirectory)\.dotnet\dotnet.exe tool run dotnet-format whitespace $(Build.SourcesDirectory)\src --folder --include-generated --include $(Build.SourcesDirectory)\src\Compilers\CSharp\Portable\Generated\ $(Build.SourcesDirectory)\src\Compilers\VisualBasic\Portable\Generated\ $(Build.SourcesDirectory)\src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\Generated\ --verify-no-changes
- task: PowerShell@2
Copy link
Member

Choose a reason for hiding this comment

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

Curious: why did you pick the PowerShell task here vs using pwsh? That is installed in our repo as a local tool. Generally I try and use that when possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do.

displayName: Validate Generated Syntax Files
inputs:
filePath: eng/validate-code-formatting.ps1
arguments: -rootDirectory $(Build.SourcesDirectory)\src -includeDirectories Compilers\CSharp\Portable\Generated\, Compilers\VisualBasic\Portable\Generated\, ExpressionEvaluator\VisualBasic\Source\ResultProvider\Generated\
Copy link
Member Author

Choose a reason for hiding this comment

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

@jaredpar I tweaked this so it doesn't assume that the SDK is installed at the root of the repo (instead, uses Ensure-DotNetSDK). I set the validation tooling to diag for this PR iteration to ensure that things are operating as expected.

I'm pretty sure that the current format command is incorrect. It appears that the include directories are expected to be paths relative to the root dir ($(Build.SourcesDirectory)\src) and not absolute paths. When I was testing it locally it was not formatting any files.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looking good now. 11 generated files from those directories checked. I changed the verbosity back down to detailed. It prints some details (number of files) that are useful.

condition: or(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['compilerChange'], 'true'))

- template: eng/pipelines/publish-logs.yml
Expand Down
2 changes: 1 addition & 1 deletion eng/SourceBuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
-->
<Target Name="ConfigureInnerBuildArg" BeforeTargets="GetSourceBuildCommandConfiguration">
<PropertyGroup>
<InnerBuildArgs>$(InnerBuildArgs) /p:Projects="$(InnerSourceBuildRepoRoot)\Roslyn.sln"</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:Projects="$(InnerSourceBuildRepoRoot)Roslyn.sln"</InnerBuildArgs>
</PropertyGroup>
</Target>

Expand Down
3 changes: 1 addition & 2 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,7 @@ try {
Setup-IntegrationTestRun
}

$global:_DotNetInstallDir = Join-Path $RepoRoot ".dotnet"
InstallDotNetSdk $global:_DotNetInstallDir $GlobalJson.tools.dotnet
$dotnet = (InitializeDotNetCli -install:$true)
}

if ($restore) {
Expand Down
1 change: 1 addition & 0 deletions eng/generate-compiler-code.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function Run-LanguageCore($language, $languageSuffix, $languageDir, $syntaxProje
function Test-GeneratedContent($generatedDir, $scratchDir) {
$algo = "MD5"
foreach ($fileName in (Get-ChildItem $scratchDir)) {
$fileName = $fileName.Name
Copy link
Member

Choose a reason for hiding this comment

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

Why was this change needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

On my local powershell installation (powershell core 7), Get-ChildItem is returning full file objects. So when you do Join-Path below you actually get:

C:\r\roslyn\src\generatedfoobar\C:\r\roslyn\src\generatedfoobar\Foo.cs

Copy link
Member Author

Choose a reason for hiding this comment

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

I can definitely revert this if you want.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tweaked this so that it selects Name explicitly.

Write-Host "Checking $fileName"
$realFilePath = Join-Path $generatedDir $fileName
$scratchFilePath = Join-Path $scratchDir $fileName
Expand Down
21 changes: 21 additions & 0 deletions eng/validate-code-formatting.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
param (
[string]$rootDirectory,
[string[]]$includeDirectories
)

try {
. (Join-Path $PSScriptRoot "build-utils.ps1")
Push-Location $RepoRoot

$dotnet = Ensure-DotnetSdk
Exec-Console $dotnet "tool run dotnet-format -v detailed whitespace $rootDirectory --folder --include-generated --include $includeDirectories --verify-no-changes"

exit 0
Copy link
Member

Choose a reason for hiding this comment

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

Why did you use exit here vs. ExitWithCode?

Copy link
Member Author

Choose a reason for hiding this comment

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

}
catch {
Write-Host $_
exit 1
}
finally {
Pop-Location
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<IsPackable>true</IsPackable>
<PackageId>Microsoft.CodeAnalysis.Test.Utilities</PackageId>
<PackageDescription>This is an internal package for testing. Not meant for external or production uses. The API can and will break at our discretion.</PackageDescription>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Compilers\Test\Resources\Core\Microsoft.CodeAnalysis.Compiler.Test.Resources.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageId>Microsoft.CodeAnalysis.Compiler.Test.Resources</PackageId>
<PackageDescription>This is an internal package for testing. Not meant for external or production uses. The API can and will break at our discretion.</PackageDescription>
<NoWarn>$(NoWarn),NU5100,NU5106,CS1591</NoWarn>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\..\Core\Portable\Microsoft.CodeAnalysis.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<NoStdLib>true</NoStdLib>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Test\PdbUtilities\Roslyn.Test.PdbUtilities.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<NoWarn>$(NoWarn);42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<TargetFrameworks>$(NetRoslynAll);net472</TargetFrameworks>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\..\..\Test\PdbUtilities\Roslyn.Test.PdbUtilities.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<UseWpf>true</UseWpf>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<UseWpf>true</UseWpf>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup>
<!-- Prevents ambiguity caused by InternalsVisibleTo from dependent assemblies. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<UseWpf>true</UseWpf>
<RootNamespace></RootNamespace>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFramework>net472</TargetFramework>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup Label="File References">
<Reference Include="System" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFramework>net472</TargetFramework>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>

<!-- Disable CA1825 (Avoid unnecessary zero-length array allocations. Use Array.Empty<X>() instead) as Array.Empty not available in one of the targets for this shared project -->
<NoWarn>$(NoWarn);CA1825</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<TargetFrameworks>$(NetRoslynAll);net472</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<TargetFrameworks>$(NetRoslynAll);net472</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"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>
Copy link
Member

Choose a reason for hiding this comment

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

Curious: if we set something as excluded from vertical build is it automatically excluded from source build? That would save us a lot of duplicate properties if true.

Copy link
Member Author

Choose a reason for hiding this comment

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

It will with the new unified build controls. "ExcludeFromVerticalBuild" is the PoC switch. It becomes a general ExcludeFromDotNetBuild switch, while ExcludeFromSourceOnlyBuild becomes the specific switch that says; "When you have access to no outside binaries, exclude this project".

</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<NoStdLib>true</NoStdLib>
<IsShipping>false</IsShipping>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@
</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'">
Condition="'$(DotNetBuildFromSource)' != 'true' and '$(DotNetBuildVertical)' != 'true'">

<ItemGroup>
<_File Include="@(DesktopCompilerArtifact)">
Expand Down
3 changes: 3 additions & 0 deletions src/Setup/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
<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>
Copy link
Member

Choose a reason for hiding this comment

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

Having both properties seems unnecessary. What code is excuded from the vertical build but included in source build?

Copy link
Member Author

Choose a reason for hiding this comment

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

Expect this to go away when the new Unified build controls come to this repo. That will happen after the implementation is complete (very soon) and when Roslyn moves to .NET 9 Arcade (late). Whenever you see both of these conditions, they would be replaced by ExcludeFromDotNetBuild

</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions src/Test/PdbUtilities/Roslyn.Test.PdbUtilities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<TargetFrameworks>$(NetRoslynAll);net472</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests" />
Expand Down
3 changes: 3 additions & 0 deletions src/Tools/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
<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 @@ -12,8 +12,9 @@
A supporting package for ASP.NET Core:
https://github.com/dotnet/aspnetcore
</PackageDescription>
<!-- Referenced by dotnet/aspnetcore and included in SDK. Requires source build -->
<!-- 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,6 +12,7 @@
A supporting package for Razor:
https://github.com/dotnet/razor
</PackageDescription>
<ExcludeFromVerticalBuild>false</ExcludeFromVerticalBuild>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<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
1 change: 1 addition & 0 deletions src/Tools/Source/RunTests/RunTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<TargetFramework>$(NetRoslyn)</TargetFramework>
<SignAssembly>false</SignAssembly>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" />
Expand Down
3 changes: 3 additions & 0 deletions src/VisualStudio/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
<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 @@ -7,6 +7,7 @@
<UseWpf>true</UseWpf>
<RootNamespace></RootNamespace>
<IsShipping>false</IsShipping>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<TargetFrameworks>$(NetRoslynAll);net472</TargetFrameworks>
<IsShipping>false</IsShipping>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
<IsTestUtilityProject>true</IsTestUtilityProject>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\Compilers\Test\Core\Microsoft.CodeAnalysis.Test.Utilities.csproj" />
Expand Down