Visual Studio- Illegal characters in path

13,316

Solution 1

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>
      ..\..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll
      </HintPath>
</Reference>

Change this to:

 <Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <HintPath>..\..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
 </Reference>

Solution 2

I had a similar problem but in my case, it was down to strange characters in a Reference:

<Reference Include="Office, Version=11.0.0.0, &#xD;&#xA;        Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<Reference Include="stdole, Version=7.0.3300.0, &#xD;&#xA;        Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

Changing the above to:

<Reference Include="Office, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<Reference Include="stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

Resolved this particular issue.

Tip: I resolved this with trial and error. I commented out all of the ItemGroups in the csproj file and reintroduced them one by one. Although your project may fail to build during this process it is clear when the above error occurs as you will see just this error and not other build errors due to missing ItemGroups.

Solution 3

@Delfi - I updated VS 2017 on Friday 2017-08-18 and starting getting the same "ResolvePackageFileConflicts" build error today on some projects. I noticed the issue happening when any reference in the .csproj file has a Hintpath. After using Notepad to remove the Hintpath from affected references the builds work fine now.

This appears to be an issue with the latest VS 2017 update. Visual C# 2017 00369-60000-00001-AA019 Microsoft Visual C# 2017

Example:

<Reference Include="Atalasoft.dotImage.WinControls, Version=10.0.6.53316, Culture=neutral, PublicKeyToken=2b02b46f7326f73b, processorArchitecture=x86">
 <HintPath>..\..\..\..\..\Program Files\Atalasoft\DotImage 10.0\bin\4.0\Atalasoft.dotImage.WinControls.dll</HintPath>
  <SpecificVersion>False</SpecificVersion>
</Reference>

Changed to...

*<Reference Include="Atalasoft.dotImage.WinControls, Version=10.5.0.61849, Culture=neutral, PublicKeyToken=2b02b46f7326f73b, processorArchitecture=x86">
  <SpecificVersion>False</SpecificVersion>
</Reference>*

Hope this helps you with your issue.

Note: I did not try it but this could also probably be fixed by removing and re-adding the affected references in the project through the solution explorer.

Solution 4

This solution works if you are facing the problem with Azure Function.

  1. Close your Visual Studio
  2. Type %localappdata% in Start(Window Search)
  3. Delete Folder AzureFunctionsTools
  4. Restart Visual Studio
  5. Select Your Project and Run.

It works!

Share:
13,316
Lukas Forst
Author by

Lukas Forst

Updated on June 14, 2022

Comments

  • Lukas Forst
    Lukas Forst almost 2 years

    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:\tmp\backend\Tests\DataLoader.Tests\bin\Debug\DataLoader.Tests.dll' could not be found EResourceConnector.Tests C:\tmp\backend\Tests\EResourceConnector.Tests\CSC 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

    ScreenShot of the errors from this project.