dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.7k stars 3.98k forks source link

Can only build Roslyn.sln a single time before building breaks (2) #74156

Open CyrusNajmabadi opened 1 week ago

CyrusNajmabadi commented 1 week ago

Using:

image

Repro steps.

  1. Build Roslyn.sln.
  2. Build Roslyn.sln again

First time succeeds with:

WARNING: Potential build performance issue in 'IntegrationTestBuildProject.csproj'. The project does not appear up-to-date after a successful build: Output 'D:\github\roslyn\artifacts\bin\IntegrationTestBuildProject\Debug\net45\IntegrationTestBuildProject.dll' does not exist, not up-to-date. See https://aka.ms/incremental-build-failure.
========== Rebuild All: 207 succeeded, 0 failed, 0 skipped ==========
========== Rebuild completed at 2:10 PM and took 03:20.100 minutes ==========

Second time fails with:

...
8>Roslyn.VisualStudio.Setup -> D:\github\roslyn\artifacts\bin\Roslyn.VisualStudio.Setup\Debug\net472\Roslyn.VisualStudio.Setup.dll
8>InteractiveHost64 -> D:\github\roslyn\artifacts\bin\InteractiveHost64\Debug\net8.0-windows\win-x64\publish\
8>InteractiveHost64 -> D:\github\roslyn\artifacts\bin\InteractiveHost64\Debug\net472\win-x64\publish\
8>InteractiveHost32 -> D:\github\roslyn\artifacts\bin\InteractiveHost32\Debug\net472\InteractiveHost32.exe
8>D:\github\roslyn\src\VisualStudio\CSharp\Impl\Options\Formatting\FormattingOptionPageControl.xaml.cs(16,35,16,59): error CS0281: Friend access was granted by 'Microsoft.VisualStudio.LanguageServices.Implementation, Version=42.42.42.42, Culture=neutral, PublicKeyToken=31bf3856ad364e35', but the public key of the output assembly ('') does not match that specified by the InternalsVisibleTo attribute in the granting assembly.
8>CSC : error CS8102: Public signing was specified and requires a public key, but no public key was specified.
8>D:\github\roslyn\src\VisualStudio\CSharp\Impl\ChangeSignature\CSharpChangeSignatureViewModelFactoryService.cs(14,85,14,115): error CS0281: Friend access was granted by 'Microsoft.VisualStudio.LanguageServices, Version=42.42.42.42, Culture=neutral, PublicKeyToken=31bf3856ad364e35', but the public key of the output assembly ('') does not match that specified by the InternalsVisibleTo attribute in the granting assembly.
8>D:\github\roslyn\src\VisualStudio\CSharp\Impl\Interactive\CSharpVsInteractiveWindowPackage.cs(8,70,8,75): error CS0281: Friend access was granted by 'Microsoft.VisualStudio.LanguageServices, Version=42.42.42.42, Culture=neutral, PublicKeyToken=31bf3856ad364e35', but the public key of the output assembly ('') does not match that specified by the InternalsVisibleTo attribute in the granting assembly.
8>D:\github\roslyn\src\VisualStudio\CSharp\Impl\Interactive\CSharpVsInteractiveWindowProvider.cs(22,70,22,75): error CS0281: Friend access was granted by 'Microsoft.VisualStudio.LanguageServices, Version=42.42.42.42, Culture=neutral, PublicKeyToken=31bf3856ad364e35', but the public key of the output assembly ('') does not match that specified by the InternalsVisibleTo attribute in the granting assembly.
8>D:\github\roslyn\src\VisualStudio\CSharp\Impl\Options\CSharpVisualStudioOptionStorageReadFallbacks.cs(64,105,64,125): error CS0281: Friend access was granted by 'Microsoft.VisualStudio.LanguageServices, Version=42.42.42.42, Culture=neutral, PublicKeyToken=31bf3856ad364e35', but the public key of the output assembly ('') does not match that specified by the InternalsVisibleTo attribute in the granting assembly.
8>D:\github\roslyn\src\VisualStudio\CSharp\Impl\ChangeSignature\CSharpChangeSignatureViewModelFactoryService.cs(19,67,19,105): error CS0281: Friend access was granted by 'Microsoft.VisualStudio.LanguageServices, Version=42.42.42.42, Culture=neutral, PublicKeyToken=31bf3856ad364e35', but the public key of the output assembly ('') does not match that specified by the InternalsVisibleTo attribute in the granting assembly.
8>D:\github\roslyn\src\VisualStudio\CSharp\Impl\ObjectBrowser\CSharpLibraryService.cs(17,43,17,65): error CS0281: Friend access was granted by 'Microsoft.VisualStudio.LanguageServices, Version=42.42.42.42, Culture=neutral, PublicKeyToken=31bf3856ad364e35', but the public key of the output assembly ('') does not match that specified by the InternalsVisibleTo attribute in the granting assembly.
8>D:\github\roslyn\src\VisualStudio\CSharp\Impl\LanguageService\CSharpCodeCleanupFixerProvider.cs(19,53,19,85): error CS0281: Friend access was granted by 'Microsoft.VisualStudio.LanguageServices, Version=42.42.42.42, Culture=neutral, PublicKeyToken=31bf3856ad364e35', but the public key of the output assembly ('') does not match that specified by the InternalsVisibleTo attribute in the granting assembly.
8>D:\github\roslyn\src\VisualStudio\CSharp\Impl\Options\AdvancedOptionPage.cs(13,41,13,59): error CS0281: Friend access was granted by 'Microsoft.VisualStudio.LanguageServices.Implementation, Version=42.42.42.42, Culture=neutral, PublicKeyToken=31bf3856ad364e35', but the public key of the output assembly ('') does not match that specified by the InternalsVisibleTo attribute in the granting assembly.
...
12>Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests -> D:\github\roslyn\artifacts\bin\Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests\Debug\net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests.dll
12>Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests -> D:\github\roslyn\artifacts\bin\Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests\Debug\net8.0\Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests.dll
========== Build: 7 succeeded, 5 failed, 195 up-to-date, 0 skipped ==========
========== Build completed at 2:15 PM and took 23.812 seconds ==========
arkalyanms commented 5 days ago

@CyrusNajmabadi is this both cmdline and vs?

CyrusNajmabadi commented 5 days ago

no. just VS> i don't use the command line :)

arkalyanms commented 5 days ago

@jjonescz Compile error + Tiger. Would you scout and transition to next Tiger as necessary?

jjonescz commented 5 days ago

The main error seems to be

CSC error CS8102: Public signing was specified and requires a public key, but no public key was specified. [D:\roslyn-D\src\VisualStudio\CSharp\Impl\Microsoft.VisualStudio.LanguageServices.CSharp.csproj]

Indeed in the binlog I can see the key is not provided to csc.

Adding <PublicSign>False</PublicSign> to Microsoft.VisualStudio.LanguageServices.CSharp.csproj is one way to work around the problem (but not sure if it doesn't cause other issues).

It seems the underlying bug is that CoreCompile target uses the KeyOriginatorFile property which is set by target ResolveKeySource but that target is not a dependency of CoreCompile (although it's a dependency of CoreBuild and Compile). Most of the time, the ResolveKeySource actually runs before CoreCompile so it works fine, but not in this case (not sure why exactly).

So adding <CoreCompileDependsOn>$(CoreCompileDependsOn);ResolveKeySource</CoreCompileDependsOn> somewhere works around the problem.

I've opened an issue at MSBuild: https://github.com/dotnet/msbuild/issues/10306 And a workaround here: https://github.com/dotnet/roslyn/pull/74205

Outdated In Error List I see this additional error (but not always, so might be unrelated/flaky thing): |Severity| Code| Description| Project| File| Line| Suppression State| Details| |---|---|---|---|---|---|---|---| |Error (active)| VSSDK1044| Could not find project VisualStudioSetup referenced from source.extension.vsixmanifest. Please add a ProjectReference to VisualStudioSetup or correct project name in source.extension.vsixmanifest.| ExpressionEvaluatorPackage, Microsoft.VisualStudio.IntegrationTest.Setup| C:\\.tools\\.nuget\packages\microsoft.vssdk.buildtools\17.9.3137-preview3\tools\vssdk\Microsoft.VsSDK.targets| 120 |