Skip to content

Can no longer use relative pathing #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
whodges opened this issue Jan 23, 2025 · 14 comments
Open

Can no longer use relative pathing #148

whodges opened this issue Jan 23, 2025 · 14 comments

Comments

@whodges
Copy link

whodges commented Jan 23, 2025

When I run "dnt switch-to-projects" now with my switcher.json as something along the lines of:

{
  "solution": "Solution.sln",
  "mappings": {
    "Project": "../Project/Project.csproj"
  }
}

I get the following error that's caused by my use of relative pathing:

Executing: dotnet
Names cannot:
- contain any of the following characters: / ? : \ * " < > |
- contain control characters
- be system reserved names, including 'CON', 'AUX', 'PRN', 'COM1' or 'LPT2'
- be '.' or '..' (Parameter 'name')
System.InvalidOperationException: Process execution failed: dotnet
   at Dnt.Commands.Infrastructure.ProcessUtilities.ExecuteAsync(String command, String arguments, Boolean verbose, Boolean writeConsole, CancellationToken cancellationToken) in C:\projects\dnt\src\Dnt.Commands\Infrastructure\ProcessUtilities.cs:line 60
   at Dnt.Commands.CommandBase.ExecuteCommandAsync(String command, String arguments, Boolean writeConsole, IConsoleHost host, CancellationToken cancellationToken) in C:\projects\dnt\src\Dnt.Commands\CommandBase.cs:line 30
   at Dnt.Commands.Packages.SwitchPackagesToProjectsCommand.AddProjectsToSolutionAsync(ReferenceSwitcherConfiguration configuration, IConsoleHost host) in C:\projects\dnt\src\Dnt.Commands\Packages\SwitchPackagesToProjectsCommand.cs:line 57
   at Dnt.Commands.Packages.SwitchPackagesToProjectsCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\dnt\src\Dnt.Commands\Packages\SwitchPackagesToProjectsCommand.cs:line 29
   at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input)
   at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
   at NConsole.CommandLineProcessor.Process(String[] args, Object input)
   at Dnt.Program.Main(String[] args) in C:\projects\dnt\src\Dnt\Program.cs:line 33

If I take out the ".." and use an absolute path, everything is fine. I updated my DNT installation (I was on 1.9.0 and now I'm on 2.0.1) and it happened with both. I did update Visual Studio to 17.13.0 Preview 3 recently (from Preview 2). Could it possibly be tied to that? Something with the build tools?

@whodges
Copy link
Author

whodges commented Jan 24, 2025

Actually, even absolute paths are insufficient when the folder isn't somewhere under the current working directory because the ":" is also banned too.

@whodges
Copy link
Author

whodges commented Jan 24, 2025

Last note: when I roll back to 17.13.0 Preview 2.1, the problem goes away. I've submitted a VS ticket.

@lucaritossa
Copy link

@whodges thank you for your details.
Could you share the link of your submitted VS ticket so we can follow it?

@whodges
Copy link
Author

whodges commented Feb 16, 2025

It’s here: https://developercommunity.visualstudio.com/t/Can-no-longer-use-relative-pathing-with-/10834141

But of course they closed it instantly, citing it as a “third party issue”.

@ssteiner
Copy link

ssteiner commented Feb 17, 2025

Just ran into this headfirst today, too. I upgraded VS to 17.13.0 release version when it came out. No changes to dnt.
Funny enough, for me with dnt 1.9.0 it still works for some projects, but fails for others - and funny enough, all my switcher files contain relative paths.

So, I've tried debugging the problem using the latest dnt version from Github. First I upgraded all packages (it was using 17.12.x packages, now I'm on 17.13.x). Then removed multi-targetting, limiting the output to .NET9 (otherwise MSBuildLocator.RegisterDefaults() bombs out) Here's where things go wrong:

in SwitchPackagesToProjects.cs methode AddProjectsToSolutionAsync - this used the dntnet sln command to add csproj files to the solution. And, it uses absolute paths. Here's an example from one of my projects:

sln "D:\Repos\AUDM\UnifiedProvisioning\UnifiedUCProvisioningCore\UnifiedUCProvisioningCore-dev.sln" add "D:\Repos\Supplier\Alcatel\AlcatelCtiApi\AlcatelCtiApi\AlcatelCtiApiStd.csproj" "D:\Repos\Supplier\Alcatel\AlcatelCtiInterfaceAsync\AlcatelCtiInterfaceAsyncStd.csproj"

So, no relative paths, it's all absolute. Even with this example, it fails. So, base don what @whodges wrote, I figured I'd see what's different in a project where it still works

Here's the parameters for the working one

sln "D:\Repos\SmartDirectory\SmartDirectory\SmartDirectoryNG-dev.sln" add "D:\Repos\SmartDirectory\SmartDirectory\SmartDirectoryDataClasses\SmartDirectoryDataClassesStd.csproj" "D:\Repos\SmartDirectory\SmartDirectory\SmartDirectoryLib\SmartDirectoryLibStd.csproj" "D:\Repos\Tools\Tools\ToolsV4\ToolsV4\ToolsStd.csproj" "D:\Repos\Tools\Tools\ParallelUtils\ParallelUtils45\ParallelUtilsStd.csproj" "D:\Repos\SmartDirectory\ParallelDirectorySearch\SearchPluginInterface\SearchPluginInterfaceStd.csproj"

So, we can see here from the 5 projects, 3 are in the same d:\repos\SmartDirectory path. But two are in d:\repos\tools\tools, so the 'works if they share the same path root' doesn't seem to hold (project 5 also is in the same repo, but another sub-repo than the other two)

For the failing project, I removed a whole bunch of projects - maybe the first project needs to share the directory?

Here's the issue I filed: https://developercommunity.visualstudio.com/t/dotnet-sln-add-started-to-fail-after-upg/10851238

Should be harder to close that with '3rd party failure'..

Then I've been trying something - what if I add a single project and that project is in a subpath to the solution?
That works. Then I added the same project again, and another one (not in a subpath) => error. So, filesystem structure does matter - but why I have a working scenario, I currently can't fully explain.

The issue seems to stem from the .NET SDK 9.0.200 by the way... I downgraded my VS to 17.12.5 and the problem was still present - because the VS 17.14 preview relied on 9.0.200, so it wasn't uninstalled when I downgraded. When I got rid of the .NET SDK 9.0.200, the problem went away

@davidsekar
Copy link

davidsekar commented Feb 17, 2025

dotnet/sdk#46891

I have raised a bug with the dotnet SDK repo, and a fix is expected in the March update.

Current workaround:
I didn't downgrade the visual studio 2022, but installed .NET SDK 9.0.102 and renamed the 9.0.200 folder so it is no longer detected
Image

Image

@mh4647
Copy link

mh4647 commented Feb 27, 2025

Still happining

Image
Dotnet version
9.0.200

@ssteiner
Copy link

@mh4647 : if you read the post immediately above yours, you'll see that the problem is your .net version. 9.0.200 has the problem. It'll be fixed in March release SDK. In the meantime, you can downgrade the SDK. There's nothing @RicoSuter can do about this, it's a Microsoft Problem.

@mh4647
Copy link

mh4647 commented Feb 27, 2025

@ssteiner Yes, Thanks,
This is exactly waht I did to continue.

@ssteiner
Copy link

Has anybody installed the March update of VS / .NET SDK and tested if it fixes the issue? The Linked Github issue is still open, other linked issues have been marked as merged and should be in the new SDK version.

@ChristophHornung
Copy link

@ssteiner After updating to 9.0.201 dnt switch-to-projects works again for me where it did not before.

@davidsekar
Copy link

davidsekar commented Mar 12, 2025

Yes, it is working💯.
The linked GitHub issue may be this one that is still open. :)

@ssteiner
Copy link

Working here, too. So this issue can be closed.

@whodges
Copy link
Author

whodges commented Mar 16, 2025

awesome - thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants