MSTest 运行失败,因为源程序集不受信任
我刚刚将 xUnit 添加到我们的测试项目中(对于断言,我们仍然使用 MSTest 作为框架),并且测试运行立即拒绝执行任何测试。 这是错误消息:
无法对测试运行“{ .... }”进行排队 测试运行部署问题: 文件或目录的位置 “...xUnit.dll”不受信任。
I just added xUnit to our test project (for the Asserts, we're still using MSTest as the framework) and immediately the test runs refused to execute any of the tests. This is the error message:
Failed to queue test run '{ .... }'
Test run deployment issue: The
location of the file or directory
'...xUnit.dll' is not trusted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
我花了几次尝试在谷歌上找到答案,所以我把它放在这里以防其他人遇到同样的问题。 详细描述可以在 此博客帖子。
基本上,修复方法包括在 Windows 资源管理器中右键单击 dll 文件(例如 xunit.dll),转到“属性”,然后单击选项卡底部“安全”文本旁边的“取消阻止”。 Vista / Windows 2008 似乎会自动将来自其他计算机或互联网的程序集标记为不安全。
正如一些评论者提到的,您可能还需要重新启动 Visual Studio 才能生效。
It took me a few tries to find the answer in Google, so I'm putting it here in case anyone else runs into the same problem. A detailed description can be found at this blog posting.
Basically, the fix invovles right-clicking on the dll file (xunit.dll for example) in Windows Explorer, going to Properties, and clicking "Unblock" at the bottom of the tab next to the 'Security' text. It seems that Vista / Windows 2008 will automatically mark assemblies that come from other machines or the internet as unsafe.
As a couple commenters have mentioned, you may also need to restart Visual Studio for this to take effect.
在我的团队中,我们也遇到了同样的问题。
您的解决方案不起作用,但是 Charles Sterling 的这篇文章确实有所帮助。
我们使用了以下行:
In my team we had the same problem.
Your solution didn't work, but this post by Charles Sterling did help.
We used the following line:
在遇到这个问题并花费数小时试图让“解锁”坚持超过几分钟和/或找出 caspol 无济于事后,我终于通过 Google 发现了一些花絮,该程序集将是下次构建或重建项目时,它们会再次被阻止,因为它们是从原始源位置重新复制的。 (我想我从来没有注意到这种情况以前发生在引用程序集上,但无论如何......)
我对此的修复如下:
将所有需要的 DLL 复制到另一个
将
删除
Visual Studio 中的引用
物理删除
bin文件夹
解除对 DLL 的阻止
分别在他们所在的地方
被复制了
添加参考文献
返回 Visual Studio
持有点
之后的每个后续构建或重建都工作得很好
After having this issue and burning hours trying to get "Unblock" to stick longer than a few minutes and/or figuring out caspol to no avail, I finally found a little tidbit via Google that the assemblies will be blocked again the next time you build or rebuild the project, since they're re-copied from their original source location. (I guess I never noticed that this happened before with references assemblies, but anyway...)
My fix for this was the following:
Copy all the needed DLLs to another
spot for safe-keeping
Remove the
references in Visual Studio
Physically delete the DLLs in the
bin folder
Unblock the DLLs
individually in the spot where they
were copied off
Add the references
back in Visual Studio from the
holding spot
Every subsequent build or rebuild worked fine afterward.
在 XP 计算机上运行(即使安装了 .NET 3.5 SP1),我无法使此处列出的任何其他解决方案发挥作用。
但是,从相同的查尔斯·斯特林 (Charles Sterling) 的帖子,戴维·兰德曼 (Davy Landman) 引用了这一点,我终于此变体成功:
在执行这些步骤之后,我可以运行测试,包括重新启动后并重建。
编辑:如此答案中所述,您可能需要安装 .NET SDK(与 .NET 框架不同)以便在您的系统上安装 .NET 2.0 配置工具。
Running on an XP machine (even with .NET 3.5 SP1 installed) I was not able to get any of the other solutions listed here to work.
However working from the same post by Charles Sterling that Davy Landman references, I finally succeeded with this variation:
After these steps I am able to run tests, including after restarts and rebuilds.
EDIT: as described in this answer, you may need to install the .NET SDK (which is different from the .NET framework) in order to have the .NET 2.0 Configuration tool on your system.
我的起订量也有同样的问题。 但不会“解锁”。 我每次解封还是被封啊!!?
我必须解锁我下载的原始 zip 文件。 然后再次从 zip 文件中复制 DLL。 之后就可以工作了。
I had the same problem with moq. But would not 'unblock'. Every time I unblocked it, it was still blocked!?!?
I had to unblock the original zip file I downloaded. Then copy the DLL from the zip file again. It work after that.
现在看起来可能很明显,但是当我单击取消阻止时,文件被设置为只读。
只有在取消选中该属性、应用然后选择取消阻止之后,我才真正开始工作。
试一试吧。
:)
PS:我还删除了 bin 文件夹中的所有旧 dll,只是为了确保 Visual Studio 不会拾取旧的 dll。
It may seem really obvious now, but when I was clicking unblock the file was set as read-only.
Only after un-checking that attribute, applying, then selecting unblock did I actually get this working.
Give that a go.
:)
PS: I also deleted all the old dll's in my bin folder, just to make sure Visual Studio wasn't picking up the old one.
我也遇到了同样的问题,下载的 DLL 被 Vista 阻止。
您需要管理员权限才能获得文件属性上的“取消阻止”按钮。
我只是将 DLL 替换为我之前提交的源代码管理 (TFS) 中的最新版本。
I had the same problem with downloaded DLLs blocked by Vista.
You need Administrator rights to get the "Unblock" button on the file's Properties.
I simply replaced the DLLs with the latest version from source control (TFS) where I had committed them before.
文件
属性
允许
file
Properties
Allow
我还尝试在记事本++中打开该文件并重命名它。
方法略有不同,但对我有用。 然后本地文件系统认为它来自同一台机器。
I also tried opening the file in notepad++ and renaming it.
Slightly different approach, but it worked for me. The local file system then think it comes from the same machine.
需要解锁的不仅仅是moq.dll。 最新的 zip 文件包括 moq.xml 和 moq.pdb 文件 - 引用 dll 也将这两个文件复制到 bin 文件夹中。 我发现,如果这三个都没有被解除阻止,测试将无法运行。
It's not just the moq.dll that needs to be unblocked. The latest zip file includes an moq.xml and moq.pdb file - referencing the dll copies these other two files to the bin folders as well. If all three have not been unblocked the tests won't run, I found.