问题描述
这发生在 Visual Studio Community 2017 最新更新之后.每次我尝试打开我的项目时,都会收到以下警告:
<块引用>警告 IDE0006 加载项目时遇到错误.某些项目功能,例如对失败项目和依赖它的项目的完整解决方案分析,已被禁用.核心测试
然后当我运行构建时,我得到:
<块引用>错误ResolvePackageFileConflicts"任务意外失败.System.ArgumentException:路径中有非法字符.
在 System.IO.Path.CheckInvalidPathChars(字符串路径,布尔检查附加)
在 System.IO.Path.GetFileName(字符串路径)
在 Microsoft.NET.Build.Tasks.ItemUtilities.GetTargetPath(ITaskItem item)
在 Microsoft.NET.Build.Tasks.ItemUtilities.GetReferenceTargetPath(ITaskItem item)
在 Microsoft.NET.Build.Tasks.ConflictResolution.ResolvePackageFileConflicts.<>c.<ExecuteCore > b__35_1(ConflictItem ci)
在 Microsoft.NET.Build.Tasks.ConflictResolution.ConflictResolver`1.ResolveConflicts(IEnumerable`1 conflictItems,Func`2 getItemKey,Action`1 foundConflict,Boolean commitWinner,Action`1 unresolvedConflict)
在 Microsoft.NET.Build.Tasks.ConflictResolution.ResolvePackageFileConflicts.ExecuteCore()
在 Microsoft.NET.Build.Tasks.TaskBase.Execute()
在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
在 Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask >d__26.MoveNext() Core.Tests
之后
<块引用>错误 CS0006 元数据文件 'C: mpackendTestsDataLoader.TestsinDebugDataLoader.Tests.dll' 找不到 EResourceConnector.Tests C: mpackendTestsEResourceConnector.TestsCSC 1 活动
项目路径仅使用拉丁字符.在构建服务器上构建正在运行,但在上次更新 VS 后我的计算机上却没有.我尝试重新安装 VS,但没有帮助.
那么对于这个问题有什么解决方案或至少提示吗?
我试图排除受此问题影响且有效的文件.但这不是我的问题的解决方案.有趣的是,只有受影响的文件是单元测试.
我尝试使用最新的 Visual Studio 2017 在全新的 Windows 10 上构建整个解决方案,但它失败了,所以这显然是我的解决方案的问题,但仅限于新版本的 VS.我在 Visual Studio 2015 上尝试了我的解决方案并且构建工作正常.
无论如何,例如 Core.Test.csproj
文件就是导致该问题的文件之一.
在您的情况下,问题是以下参考中的行返回:
<Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><提示路径>....packagesSystem.Collections.Immutable.1.3.1libportable-net45+win8+wp8+wpa81System.Collections.Immutable.dll</提示路径></参考>
将其更改为:
<Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><HintPath>....packagesSystem.Collections.Immutable.1.3.1libportable-net45+win8+wp8+wpa81System.Collections.Immutable.dll</HintPath></参考>
This happen after Visual Studio Community 2017 latest update. Every time I try to open my project I get following warning:
Warning IDE0006 Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled. Core.Tests
Then when I run build I get:
Error The "ResolvePackageFileConflicts" task failed unexpectedly. System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
at System.IO.Path.GetFileName(String path)
at Microsoft.NET.Build.Tasks.ItemUtilities.GetTargetPath(ITaskItem item)
at Microsoft.NET.Build.Tasks.ItemUtilities.GetReferenceTargetPath(ITaskItem item)
at Microsoft.NET.Build.Tasks.ConflictResolution.ResolvePackageFileConflicts.<>c. < ExecuteCore > b__35_1(ConflictItem ci)
at Microsoft.NET.Build.Tasks.ConflictResolution.ConflictResolver`1.ResolveConflicts(IEnumerable`1 conflictItems, Func`2 getItemKey, Action`1 foundConflict, Boolean commitWinner, Action`1 unresolvedConflict)
at Microsoft.NET.Build.Tasks.ConflictResolution.ResolvePackageFileConflicts.ExecuteCore()
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.< ExecuteInstantiatedTask >d__26.MoveNext() Core.Tests
and afterwards
Error CS0006 Metadata file 'C: mpackendTestsDataLoader.TestsinDebugDataLoader.Tests.dll' could not be found EResourceConnector.Tests C: mpackendTestsEResourceConnector.TestsCSC 1 Active
Path to the project is in latin only characters. On the build server build is working but on my computer after last update of VS is not. I've tried to reinstall VS but that didn't help.
So is there any solutions or at least hint for this issue?
EDIT: I tried to exclude files which are affected by this issue and that worked. But that is not solution for my problem. Interesting is, that are only affected files are unit tests.
EDIT2: I tried to build whole solution on the fresh Windows 10 with latest Visual Studio 2017 and it's failing so it is obviously my solution's problem but only in the new version of VS. I tried my solution on the Visual Studio 2015 and build worked fine.
Anyway, here's for example Core.Test.csproj
file which is one of these that are causing that issue. https://pastebin.com/kq7MFLV1
In your case the problem is the line returns in the following reference:
<Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>
....packagesSystem.Collections.Immutable.1.3.1libportable-net45+win8+wp8+wpa81System.Collections.Immutable.dll
</HintPath>
</Reference>
Change this to:
<Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>....packagesSystem.Collections.Immutable.1.3.1libportable-net45+win8+wp8+wpa81System.Collections.Immutable.dll</HintPath>
</Reference>
这篇关于Visual Studio - 路径中的非法字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!