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

查看:97
本文介绍了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:\v7\Development\Unit_Test\GENERATEPROJECTPRIFILE    

当我在文件内容中搜索ClassComments1时,会发现以下内容:

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

  .\obj\x86\Debug\Microsoft.Build.Tasks.v4.0\en-US\System.Design.resw (1 hit)
    Line 132:   <data name="ClassComments1" xml:space="preserve">
  .\obj\x86\Debug\System.Design\en-US\System.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:错误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年赢得10位创作者的更新,然后在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天全站免登陆