【发布时间】:2020-07-09 15:46:24
【问题描述】:
使用 Microsoft.Build 组件通过 ProjectCollection.GlobalProjectCollection.LoadProject 方法加载 csproj。文档here。
在其中一个引用中加载具有 PackageReference 和 ExcludeAsset 属性的 csproj,例如:
<PackageReference Include="SomePackage" ExcludeAssets="Compile">
<Version>1.0.0</Version>
</PackageReference>
抛出以下异常:
元素中的“ExcludeAssets”属性无法识别。
已经尝试过不同的 ToolVersions (2.0 | 4.0 |12.0),并且两个项目都是在 .net472 中编译的
我该如何解决这个问题?
谢谢
【问题讨论】:
-
我相信只支持 dotnet core:docs.microsoft.com/en-us/dotnet/core/tools/csproj
-
csproj 有效且编译正确。 (带有 PackageReferences 的旧 csproj 格式)所以,根据我的理解,使用 ProjectCollection.GlobalProjectCollection.LoadProject 加载它不应该抛出任何类型的异常 thks
标签: c# msbuild csproj packagereference