UWP 单元测试编译错误 [英] UWP unit test compile errors

查看:22
本文介绍了UWP 单元测试编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 WPF 项目迁移到 UWP.在 UWP 中设置新的单元测试项目时,当新的单元测试针对迁移的项目而该项目又依赖于解决方案中的另一个项目时,我遇到了错误.(每个解决方案都没有错误)

I'm migrating WPF projects to UWP. While setting up new unit test projects in UWP I'm running into errors when the new unit test targets a migrated project that in turn has a dependency on another project in the solution. (Each solution builds w/o errors)

Solution Explorer:
Communication.Base(.csproj uwp class library)
Communication(.csProj uwp class library) -> depends on Communication.Base
Unit_Test(.csproj)

如果 Unit_Test 项目同时引用了 Communication.Base 和 Communication,我在尝试运行空测试方法时会遇到几个错误:

If Unit_Test project references both Communication.Base and Communication, I get several errors when attempting to run an empty test method:

Duplicate Entry. error PRI175       

Error       0xdef00532 - Conflicting values for resource 'System.Design/ClassComments1' Unit_Test C:v7DevelopmentUnit_TestGENERATEPROJECTPRIFILE    

当我搜索 ClassComments1 的文件内容时,我找到了这些:

When I search the file contents for ClassComments1 I find these:

  .objx86DebugMicrosoft.Build.Tasks.v4.0en-USSystem.Design.resw (1 hit)
    Line 132:   <data name="ClassComments1" xml:space="preserve">
  .objx86DebugSystem.Designen-USSystem.Design.resw (1 hit)
    Line 3821:   <data name="ClassComments1" xml:space="preserve">

不知道如何解决这些问题.有人遇到过这个问题吗?

Not sure how to fix these though. Has anyone run into this issue?

更新

在完成所有项目的迁移后,我发现这个错误影响了我编译和运行整个应用程序的能力.我已经重建了所有的项目文件(每个文件都编译并生成它的 dll)但主应用程序现在无法编译:

After finishing the migration of all projects, I find that this error effects my ability to compile and run the entire application. I've rebuilt all of the projects files (each of them compile and produce it's dll) but the main application wont compile now:

13>错误 PRI175:0x80073b0f - 处理资源失败,错误:重复条目.13>GENERATEPROJECTPRIFILE : error PRI277: 0xdef00532 - 资源System.Design/ClassComments1"的冲突值

13>error PRI175 : 0x80073b0f - Processing Resources failed with error : Duplicate Entry. 13>GENERATEPROJECTPRIFILE : error PRI277: 0xdef00532 - Conflicting values for resource 'System.Design/ClassComments1'

更新

我尝试将这个解决方案中的所有项目降级到 2017 年的 pre-win 10 creators 更新,然后在 2015 年打开了该解决方案.不幸的是,Microsoft.NetCore.UniversalWindowsPlatform 引用在打开解决方案时被破坏,2015 nuget 不能即使在选择要安装的软件包时也能成功恢复它们.在失败之前出现大量 nuget 错误.

I tried downgrading all of the project in this solution to pre-win 10 creators update in 2017 then opened the solution in 2015. Unfortunately, the Microsoft.NetCore.UniversalWindowsPlatform references are broken on opening the solution and 2015 nuget can't successfully restore them even when selecting the package to install. Tons of nuget errors before it fails.

推荐答案

通过将每个项目包含在单元测试中(每次都失败并出现相同的错误),我终于能够通过挑出有问题的项目来修复此构建错误.) 当我在测试中添加和删除项目时,我注意到似乎导致问题的项目有以下参考:

I was finally able to fix this build error by singling out the problem project by including each project in a unit test (that failed each time with the same error.) As I added and removed projects from the test, I noticed that the one that seemed to cause the issue had the following reference:

Reference Include="System.EnterpriseServices, Version=4.0.0.0

当我更新代码库以针对 UWP 进行编译时,Visual Studio 会在辅助过程中自动添加该引用.一旦我删除了这个引用,整个解决方案就会编译,没有错误.

The reference was added by Visual Studio automatically during the assist process when I was updating the code base to compile against UWP. Once I remove this reference the whole solution compiles w/o error.

这篇关于UWP 单元测试编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆