我的解决方案具有以下(简化)结构:
Application.sln
|- Business.csproj
|- DAL.vbproj
两个项目都针对.NET Framework 4.5.2。它在本地和VSTS中构建。
我现在已经在DAL项目中将一个NuGet包引用添加到.NET Standard 1.1 dll中。它仍然在我的本地机器上完美构建,但不再在VSTS上。我收到以下错误:
SGEN : error : An attempt was made to load an assembly with an incorrect format: C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime.interopservices.runtimeinformation\4.3.0\ref\netstandard1.1\System.Runtime.InteropServices.RuntimeInformation.dll. [E:\VstsAgents\2\_work\16\s\Src\Business\Business.csproj]
请注意VSTS似乎抱怨Business.csproj
而不是DAL.vbproj
。虽然Business确实引用了DAL。
我已经阅读过关于不支持.NET Standard 1.1的SGEN,但如果生成序列化程序集的选项设置为Auto
,它应该可以正常工作。我的所有项目都设置为自动。
我还读过你应该如何change the build definition,但
我应该调查the .NET Core Xml Serializer Generator吗?理想情况下,我想让我的NuGet包中的构建跳过SGEN。
更新
将system.debug
选项设置为true可为我们提供更多信息。我们有一条错误消息:cannot load a reference assembly for execution
。我们也能够在本地重现它。我的机器安装了.NET 4.7.1 SDK和目标软件包,但另一台本地机器没有安装。安装修复它。我们现在正在考虑在构建机器上安装它(显然,VSTS设置为使用内部代理)。
我相信这些是相关的日志:
2018-02-14T10:03:33.4980817Z ##[error]SGEN(0,0): Error : An attempt was made to load an assembly with an incorrect format: C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime.interopservices.runtimeinformation\4.3.0\ref\netstandard1.1\System.Runtime.InteropServices.RuntimeInformation.dll.
2018-02-14T10:03:33.4980817Z ##[debug]Processed: ##vso[task.logissue type=Error;sourcepath=SGEN;linenumber=0;columnnumber=0;code=;]An attempt was made to load an assembly with an incorrect format: C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime.interopservices.runtimeinformation\4.3.0\ref\netstandard1.1\System.Runtime.InteropServices.RuntimeInformation.dll.
2018-02-14T10:03:33.4980817Z 108>SGEN : error : An attempt was made to load an assembly with an incorrect format: C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime.interopservices.runtimeinformation\4.3.0\ref\netstandard1.1\System.Runtime.InteropServices.RuntimeInformation.dll. [E:\VstsAgents\2\_work\16\s\Src\Business\Business.csproj]
2018-02-14T10:03:33.4980817Z - Could not load file or assembly 'file:///C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime.interopservices.runtimeinformation\4.3.0\ref\netstandard1.1\System.Runtime.InteropServices.RuntimeInformation.dll' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
2018-02-14T10:03:33.4980817Z - Cannot load a reference assembly for execution.
```
答案 0 :(得分:0)
显然,在构建代理上安装.NET 4.7.1会为我们修复它。