Google Cloud Build C#源生成器,无法加载文件或汇编Microsoft.codeanalysis'

发布于 2025-01-17 21:55:50 字数 1480 浏览 4 评论 0原文

我一直在尝试在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文