Unable to build a netstandard2.0 project from a net8.0 unit test
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- csharp
- 领域
- build-system, tooling
调研方向
从单元测试项目的 MSBuildLocator.RegisterDefaults() 调用入手,将其程序集解析与成功的 dotnet build 进行比较。在目标框架为 net8.0 或 net9.0 时,复现 netstandard2.0 项目的 GenerateDepsFile 失败,然后比较测试项目安装和未安装 Microsoft.Extensions.DependencyModel 时的行为。完成标准是:无需使用该包作为变通方案,即可从单元测试构建这些项目。
由索引模型根据 Issue 内容生成。
描述
I have a unit test which builds several projects targeting net46 and netstandard2.0. net46 ones build successfully, but netstandard2.0 ones fail with the following error:
C:\Program Files\dotnet\sdk\8.0.315\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(284,5): error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.DependencyModel, Version=8.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (0x80131621)
File name: 'Microsoft.Extensions.DependencyModel, Version=8.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60'
---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.DependencyModel, Version=8.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
at Microsoft.NET.Build.Tasks.GenerateDepsFile.WriteDepsFile(String depsFilePath)
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [C:\Users\DarkDaskin\Documents\Development\UnityModStudio\UnityModStudio.Build.Tests\bin\Debug\net8.0\Projects\Correct\MultiVersionMultiTarget\MultiVersionMultiTarget.csproj]
The same projects can be built with dotnet build without problems.
I also tried to switch my unit tests to net9.0, but the same error persists (with different assembly version).
I use MSBuildLocator.RegisterDefaults(); to locate an MSBuild instance.
Installing the Microsoft.Extensions.DependencyModel package into the unit test project allows to build everything successfully, but I guess that MSBuildLocator should have loaded this assembly from the SDK directory automatically.
- 主要语言
- C#
- 星标
- 262
- 派生
- 91
- 平均合并
- 11 天 22 小时
- 30 天内合并 PR
- 3
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/MSBuildLocator 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 52/100
microsoft/MSBuildLocator#390 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 64/100
microsoft/MSBuildLocator#389 ·
-
难度 4/5 3-5 天 新手友好度 45/100
microsoft/MSBuildLocator#380 ·
-
难度 3/5 1-2 天 新手友好度 48/100
microsoft/MSBuildLocator#377 ·
-
难度 5/5 一周以上 新手友好度 30/100
microsoft/MSBuildLocator#371 · 1 条评论 ·
查看 microsoft/MSBuildLocator 的全部 Issue
相似的 Issue
-
untriaged
难度 1/5 1 小时以内 新手友好度 88/100
dotnet/dotnet-api-docs#13095 ·
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100
-
type/automation type/tech-debt
难度 2/5 1-3 小时 新手友好度 84/100
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
newrelic/newrelic-dotnet-agent#3850 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
LuckyPennySoftware/AutoMapper#4660 ·