我有一个包含3个项目的Visual Studio 2015解决方案,然后开始使用VS 2017添加2个新的xunit项目。当我构建一切成功但测试资源管理器中正在发现测试时。
我查看了这个问题Found conflicts between different versions of the same dependent assembly that could not be resolved,并将我的Build输出设置为Diagnostic,我收到一条警告说:
1> C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2052,5): warning MSB3277: Found conflicts between different versions of "System.Runtime" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
我已经更新了3个.csproj文件
Project ToolsVersion="14.0"
,以
Project ToolsVersion="15.0"
将<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
添加到没有它的2个VS2017项目中
设置测试 - &gt;测试设置 - &gt;默认处理器架构到x64和我的构建 - &gt;配置管理器 - &gt;平台到x64或任何CPU(某些项目不允许x64?)
我已使用Update-Package -reinstall
更新并修复了VS2017
我可以看到我对解决方案加载的测试,但是一旦我构建解决方案,测试就会变灰。然后我试着跑一个他们说
4/4/2018 4:34:25 PM Warning] Test run will use DLL(s) built for framework Framework45 and platform X86. Following DLL(s) will not be part of run:
DatabaseRestoreManager.exe, RestoreBaseLib.IntegrationTests.dll, RestoreBaseLib.Tests.dll, RestoreBaseLib.dll, Restores.exe are built for Framework Framework45 and Platform X64.
Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.
[4/4/2018 4:34:26 PM Warning] [xUnit.net 00:00:00.1993869] Exception discovering tests from RestoreBaseLib.IntegrationTests: System.BadImageFormatException: Could not load file or assembly 'RestoreBaseLib.IntegrationTests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'RestoreBaseLib.IntegrationTests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
大多数有这个问题的人似乎都在nuget包中遇到问题,但我的问题似乎是msbuild或VS15到VS17的升级测试和System.Runtime
。
有什么能解决这个问题吗?我希望能够在VS17中运行xunit测试。