RicoSuter / DNT

DNT (DotNetTools): Command line tools to manage .NET projects and solutions.
MIT License
413 stars 64 forks source link

Switch to projects not working for NSwag/NJsonSchema #50

Open rossknudsen opened 5 years ago

rossknudsen commented 5 years ago

I'm trying to run the standard switch to projects command for NSwag/NJsonSchema interop and hitting an issue running this command:

dnt switch-to-projects switcher.json

Which produces multiple entries like the following:

The project 'C:\Users\rossk\Documents\source\nswag\src....\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\NJsonSchema.CodeGeneration.TypeScript.csproj' could not be loaded: The imported project "C:\Program Files\dotnet\sdk\2.2.101\Current\Microsoft.Common.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. C:\Program Files\dotnet\sdk\2.2.101\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props

The projects are successfully added to the solution but the packages are not swapped for the projects. Looking at the file "C:\Program Files\dotnet\sdk\2.2.101\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props" it has the following line:

<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />

So it appears to be substituting $(MSBuildToolsVersion) with "Current" which doesn't actually exist on my system. The correct substitution seems to be "15.0" as the filepath matches. Note that I'm running VS 2017 which is version 15.0.

Any ideas on how to fix this?

rossknudsen commented 5 years ago

FYI - as a workaround and to prove this is the actual issue, I created a symlink pointing "C:\Program Files\dotnet\sdk\2.2.101\Current\" to"C:\Program Files\dotnet\sdk\2.2.101\15.0\" and the command works without an error.

Would be nice to resolve this without such a workaround though.