Search code examples
asp.net-core.net-coredotnet-cli

Dotnet watcher - Illegal characters in path -- what could cause this error?


Can anyone help us understand why dotnet watch is causing our applications to crash?

I'm using dotnet new mvc and yo aspnetcore-spa to create apps in visual studio code. Both work fine until I try to add a reference to DotNet Watcher tools using example at https://github.com/aspnet/DotNetTools/tree/dev/src/Microsoft.DotNet.Watcher.Tools to insert reference in csproj file:

<ItemGroup>
    <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
</ItemGroup>

After adding to csproj and dotnet restore, the application throws an error and fails and is unrecoverable. It has to be deleted and I have to start from scratch.

Full csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">
    <PropertyGroup>
        <TargetFramework>
            netcoreapp1.1
        </TargetFramework>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
        <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
        <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
        <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
    </ItemGroup>
    <ItemGroup>
        <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
    </ItemGroup>
</Project>

The error thrown is below and happens no matter where we create the application on disk or what it is named.

  • C:\Program Files\dotnet\sdk\1.0.1\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\Microsoft.NET.Sdk.Publish.targets(90,5): error MSB4184: The expression "[System.IO.Path]::GetFullPath(C:\test\obj\Debug\ [C:\test\test.csproj]
  • C:\Program Files\dotnet\sdk\1.0.1\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\Microsoft.NET.Sdk.Publish.targets(90,5): error MSB4184: netcoreapp1.1 [C:\test\test.csproj]
  • C:\Program Files\dotnet\sdk\1.0.1\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\Microsoft.NET.Sdk.Publish.targets(90,5): error MSB4184: \PubTmp)" cannot be evaluated. Illegal characters in path. Parameter name: path [C:\test\test.csproj]

Our environment is:

  • .NET Command Line Tools (1.0.1)
  • Microsoft .NET Core Shared Framework

  • Host Version : 1.1.0

  • Build: 928f77c4bc3f49d892459992fb6e1d5542cb5e86
  • Visual Studio Code v 1.10.2
  • Windows 10

Solution

  • Problem solved. An extension named "XML Formatter" was rewriting the csproj file on save and adding hard returns and tabs. Removing this extension, restoring csproj to it's original state, adding back in the DotNetCliToolReference code block and rebuilding via dotnet restore solved the issue.