microsoft / microsoft/MSBuildCache
Microsoft.CodeAnalysis build error
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 64
- Forks
- 24
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 2
Description
When testing out MSBuildCache on my solution, I am getting a build error related to Microsoft.CodeAnalysis 3.8.00, from one of our projects that itself references a difference Microsoft.CodeAnalysis version:
https://github.com/microsoft/MSBuildCache/blob/main/Directory.Packages.props#L29 references <PackageVersion Include="Microsoft.CodeAnalysis" Version="3.8.0" /> so it appears they are clashing?
NB I'm using dotnet build here - is it unsupported and I need a VS Install?
dotnet build -c Release
C:\Users\<snip>\.nuget\packages\microsoft.msbuildcache.sharedcompilation\0.1.318-preview\build\Microsoft.MSBuildCache.Shared
Compilation.targets(9,5): error MSB4018: The "ResolveFileAccesses" task failed unexpectedly. [C:\src\Foo\src\CodeAnalysis\src
\Foo.CodeAnalysis\Foo.CodeAnalysis.csproj]
C:\Users\<snip>\.nuget\packages\microsoft.msbuildcache.sharedcompilation\0.1.318-preview\build\Microsoft.MSBuildCache.Shared
Compilation.targets(9,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis, V
ersion=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. [C:\src\Foo\src
\CodeAnalysis\src\Foo.CodeAnalysis\Foo.CodeAnalysis.csproj]
Foo.CodeAnalysis.csproj
...
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="NETStandard.Library" />
</ItemGroup>
...
Directory.Build.props
<ItemGroup Condition="'$(MSBuildProjectName)'!='Foo.CodeAnalysis' AND '$(MSBuildProjectName)'!='Foo.CodeAnalysis.Test'">
<ProjectReference Include="$(MSBuildThisFileDirectory)\CodeAnalysis\src\Foo.CodeAnalysis\Foo.CodeAnalysis.csproj"
PrivateAssets="all"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer"/>
</ItemGroup>
Directory.Packages.props
...
<ItemGroup >
<GlobalPackageReference Include="Microsoft.MSBuildCache.SharedCompilation" Version="0.1.318-preview" />
<GlobalPackageReference Include="Microsoft.MSBuildCache.Local" Version="0.1.318-preview" />
</ItemGroup>
...
<PackageVersion Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.0.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="4.0.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.0.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.NUnit" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.NUnit" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.Features" Version="4.0.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Scripting.Common" Version="4.0.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.0.1" />
...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with dotnet build -c Release, then inspect Directory.Packages.props, Directory.Build.props, and Foo.CodeAnalysis.csproj alongside the Microsoft.MSBuildCache.SharedCompilation targets named in the error. Trace the Microsoft.CodeAnalysis version mismatch and verify that the affected project builds successfully without the ResolveFileAccesses assembly-load failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100