avalonia-dotnet-templates icon indicating copy to clipboard operation
avalonia-dotnet-templates copied to clipboard

dotnet new template generates faulty sln when hyphen is in the path

Open AArnott opened this issue 1 year ago • 1 comments

Describe the bug

dotnet new generated avalonia solutions are broken when the solution directory contains a hyphen.

To Reproduce

dotnet new avalonia.xplat -o avalonia-test
avalonia-test\avalonia-test.sln

This repros even without the -o switch if the current directory contains a hyphen.

The solution is full of bad relative paths to project files, so all the projects fail to load: image

It becomes clear why this is when the created project files are compared to what's in the sln file:

Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "avalonia_test", "avalonia_test\avalonia_test.csproj", "{EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}"
EndProject

Note how the hyphen in the solution directory name has been changed to the underscore character. Yet this translation did not actually happen on disk: the project directories and project filenames use a hyphen.

The generated ProjectReference items in the project files have a similar bug in using underscore instead of hyphen.

Expected behavior

The solution loads successfully in Visual Studio. The project files use a hyphen and so do references to those projects in the sln file.

Desktop (please complete the following information):

  • OS: Windows 11
  • Version: I don't know how to look up the version of the template. But I installed it in the last couple weeks.

AArnott avatar Feb 21 '23 03:02 AArnott

Related https://github.com/dotnet/templating/issues/402

maxkatz6 avatar Feb 21 '23 07:02 maxkatz6