-
Notifications
You must be signed in to change notification settings - Fork 68
Closed
Labels
Description
Describe the bug
I get errors when I try to open a dotnet project with Visual Studio 2022 community edition that uses the Directory.Build.props and Directory.Build.props files generated by nx-dotnet.
To Reproduce
Steps to reproduce the behavior:
- Generate a nx-dotnet app with a sln.
- Open the sln in Visual Studio 2022 community edition.
- Observe that the project(s) are not actually loaded.
- Right click on the project that failed to load and click on "Reload Project"
- Observe error in popup dialog and in build output window.
---------------------------
Microsoft Visual Studio
---------------------------
Invalid static method invocation syntax: "[System.IO.Path]::GetRelativePath($(RepoRoot), $(MSBuildProjectDirectory))". Method 'System.IO.Path.GetRelativePath' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)). Check that all parameters are defined, are of the correct type, and are specified in the right order. C:\Repos\MyProject\Directory.Build.props
---------------------------
OK
---------------------------
Environment:
- OS: Windows 11
- IDE: Visual Studio 2022 community edition
Possible solution
I found the relevant documentation and it says any function in the System.IO.Path class should be invokable from these "property functions." So, it should work. It doesn't work on my box. There is another option that does work on my box and that's [MSBuild]::MakeRelative, which looks to be a drop-in replacement for [System.IO.Path]::GetRelativePath in this context.
This is the change I've made on my projects. I'm happy to submit a pull request if that helps.