Google Cloud Build C#源生成器,无法加载文件或汇编Microsoft.codeanalysis'
我一直在尝试在Google Cloud构建期间使用C#源生成器,但我一直遇到错误:
步骤#1-“构建”:CSC:警告CS8032:无法从 / /无法创建Analyzer Generator /sourcegenerator的实例layers/google.dotnet.publish/packages/generator/2.0.0/Analyzers/dotnet/cs/generator.dll:无法加载文件或汇编'microsoft.codeanalisy,版本= 4.1.0.0,culture = 4.1.0 '。系统找不到指定的文件。[/workSpace/generator-app/generator-app.csproj]
应用程序CSPROJ的一部分使用了生成器:
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
源生成器CSPROJ:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.1.0" />
</ItemGroup>
</Project>
我试图降级Microsoft。 CodeAnalysis.csharp和Microsoft.codeanalysis.analyzers软件包,但这不起作用。
Google Cloud Build使用SDK版本:3.1.416
I have been trying to use an C# source generator during the Google Cloud Build but i keep getting an error:
Step #1 - "build": CSC : warning CS8032: An instance of analyzer generator/sourceGenerator cannot be created from /layers/google.dotnet.publish/packages/generator/2.0.0/analyzers/dotnet/cs/generator.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.. [/workspace/generator-app/generator-app.csproj]
Part of the application csproj that uses the generator:
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
The source generator csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.1.0" />
</ItemGroup>
</Project>
I have tried to downgrade the Microsoft.CodeAnalysis.CSharp and Microsoft.CodeAnalysis.Analyzers packages but that does not work.
Google cloud build uses SDK Version: 3.1.416
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论