有没有办法在没有 AnyCPU 的情况下构建 VS 单元测试
Is there a way to build VS unit tests without AnyCPU
我为 HTML5+JavaScript 库开发了一个 C# API – 我使用 CefSharp 作为中间层。现在我需要创建一些单元测试,以确保 API 有效。问题是 CefSharp 不能(简单地)与 AnyCPU 一起使用,而 VisualStudio 的单元测试必须为 AnyCPU 构建。当我尝试 运行 测试时,这会导致错误:CefSharp.Common will work out of the box if you specify platform (x86/x64).
有没有办法克服这些限制中的任何一个?
我知道 CefSharp 应该以某种方式与 AnyCPU 兼容,但我无法得到它 运行ning.
编辑
现在我没有收到第一个错误,但我收到了另一个错误:
System.IO.FileNotFoundException: Could not load file or assembly CefSharp, Version=57.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138 or one of its dependencies. The specified module could not be found.
File name: CefSharp, Version=57.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138
in CefSharp.CefSharpApp.OnBeforeChildProcessLaunch(CefSharpApp* , scoped_refptr<CefCommandLine>* commandLine)
.
这是 Fusion View 的日志:
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.x86.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: CefSharp, Version=57.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/CefSharp.DLL
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/CefSharp/CefSharp.DLL
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Extensions/CefSharp.DLL
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Extensions/CefSharp/CefSharp.DLL
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/CefSharp.EXE
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/CefSharp/CefSharp.EXE
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Extensions/CefSharp.EXE
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Extensions/CefSharp/CefSharp.EXE
相关 GitHub 问题 here。
如果到目前为止您对我的代码感兴趣:
GitHub link(不太相关)
第一个问题
我发现设置 Test>Test Settings>Default Architecture
还不够,我还必须将 整个项目 设置为 x86
或 [=12] =].首先你必须打开配置管理器。
.
然后您需要为您的测试项目创建 x82
和 x64
平台。
.
如果你喜欢,一定要注意the most overlooked checkbox in Visual Studio. This checkbox needs to be checked if the platform you're creating doesn't exist in any other project of your solution and unchecked otherwise. I'm sure this is also the most useless checkbox in Visual Studio, you can vote for its removal。
现在将为您选择的平台构建您的测试!
.
第二题
这是 another SO question and is probably caused by CefSharp being a NuGet package written in C++/CLI. I don't really understand this but a wise man on GitHub found a solution 的副本。
我为 HTML5+JavaScript 库开发了一个 C# API – 我使用 CefSharp 作为中间层。现在我需要创建一些单元测试,以确保 API 有效。问题是 CefSharp 不能(简单地)与 AnyCPU 一起使用,而 VisualStudio 的单元测试必须为 AnyCPU 构建。当我尝试 运行 测试时,这会导致错误:CefSharp.Common will work out of the box if you specify platform (x86/x64).
有没有办法克服这些限制中的任何一个?
我知道 CefSharp 应该以某种方式与 AnyCPU 兼容,但我无法得到它 运行ning.
编辑
现在我没有收到第一个错误,但我收到了另一个错误:
System.IO.FileNotFoundException: Could not load file or assembly CefSharp, Version=57.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138 or one of its dependencies. The specified module could not be found.
File name: CefSharp, Version=57.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138
in CefSharp.CefSharpApp.OnBeforeChildProcessLaunch(CefSharpApp* , scoped_refptr<CefCommandLine>* commandLine)
.
这是 Fusion View 的日志:
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.x86.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: CefSharp, Version=57.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/CefSharp.DLL
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/CefSharp/CefSharp.DLL
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Extensions/CefSharp.DLL
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Extensions/CefSharp/CefSharp.DLL
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/CefSharp.EXE
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/CefSharp/CefSharp.EXE
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Extensions/CefSharp.EXE
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Extensions/CefSharp/CefSharp.EXE
相关 GitHub 问题 here。
如果到目前为止您对我的代码感兴趣: GitHub link(不太相关)
第一个问题
我发现设置 Test>Test Settings>Default Architecture
还不够,我还必须将 整个项目 设置为 x86
或 [=12] =].首先你必须打开配置管理器。
.
然后您需要为您的测试项目创建 x82
和 x64
平台。
.
如果你喜欢,一定要注意the most overlooked checkbox in Visual Studio. This checkbox needs to be checked if the platform you're creating doesn't exist in any other project of your solution and unchecked otherwise. I'm sure this is also the most useless checkbox in Visual Studio, you can vote for its removal。
现在将为您选择的平台构建您的测试!
.
第二题
这是 another SO question and is probably caused by CefSharp being a NuGet package written in C++/CLI. I don't really understand this but a wise man on GitHub found a solution 的副本。