Skip to content
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

Projects are not loaded when the code is in network mapped drive #305

Closed
viveknuna opened this issue Nov 16, 2021 · 4 comments · Fixed by #306
Closed

Projects are not loaded when the code is in network mapped drive #305

viveknuna opened this issue Nov 16, 2021 · 4 comments · Fixed by #306
Labels
bug Something isn't working

Comments

@viveknuna
Copy link

I have installed the tool by running the below command yesterday.

dotnet tool install --global Microsoft.VisualStudio.SlnGen.Tool

Then I run the below command to generate the solution.

@ECHO OFF
slngen --launch:false --folders:true --collapsefolders:true --solutiondir:src --solutionfile:MySolution.sln --ignoreMainProject --verbosity:normal **.csproj **.sqlproj
REM --verbosity:diag

It works as expected when my code is in C drive, But when my code is in J drive which is a network drive. It gives the below errors when I open the solution in Vishal Studio 2019.

One or more projects in the solution were not loaded correctly. Please see the Output window for details.

Error in the output window.

J:\folder\UNC\SUKWGWGDSPASDF1\VDIUsers$\User.Name\folder\src\shared\Common\MyProject.Common.csproj : error : The project file cannot be found.

How to fix it? I have to use the J drive, It's required.

@jeffkl
Copy link
Collaborator

jeffkl commented Nov 16, 2021

@viveknuna is there a way to share the generated solution file?

I think its because of this code:

if (Utility.RunningOnWindows)
{
using FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
StringBuilder stringBuilder = new StringBuilder(GetFinalPathNameByHandle(stream.SafeFileHandle, null, 0, 0));
GetFinalPathNameByHandle(stream.SafeFileHandle, stringBuilder, stringBuilder.Capacity, 0);
return stringBuilder.ToString(4, stringBuilder.Capacity - 5);

This is trying to determine the "real" path of a file if the casing is wrong which can happen when people manually type in the path to a project in a <ProjectReference /> item. But since you're using a mapped drive, I suspect this method is returning something that Visual Studio cannot understand. I'll try to find some time today to reproduce the issue.

@jeffkl jeffkl added the bug Something isn't working label Nov 16, 2021
@viveknuna
Copy link
Author

@jeffkl sure, thank you for responding, I'll wait for the update.

jeffkl added a commit to jeffkl/SlnGen that referenced this issue Nov 16, 2021
On Windows, the GetFinalPathNameByHandle function returns the UNC path if the specified path is from a mapped network drive.  These paths break Visual Studio so they can't be used.  This change detects if the path was normalized and isn't from a network drive, otherwise the original path is used.

Fixes microsoft#305
jeffkl added a commit to jeffkl/SlnGen that referenced this issue Nov 16, 2021
On Windows, the GetFinalPathNameByHandle function returns the UNC path if the specified path is from a mapped network drive.  These paths break Visual Studio so they can't be used.  This change detects if the path was normalized and isn't from a network drive, otherwise the original path is used.

Fixes microsoft#305
jeffkl added a commit to jeffkl/SlnGen that referenced this issue Nov 16, 2021
On Windows, the GetFinalPathNameByHandle function returns the UNC path if the specified path is from a mapped network drive.  These paths break Visual Studio so they can't be used.  This change detects if the path was normalized and isn't from a network drive, otherwise the original path is used.

Fixes microsoft#305
jeffkl added a commit that referenced this issue Nov 16, 2021
On Windows, the GetFinalPathNameByHandle function returns the UNC path if the specified path is from a mapped network drive.  These paths break Visual Studio so they can't be used.  This change detects if the path was normalized and isn't from a network drive, otherwise the original path is used.

Fixes #305
@viveknuna
Copy link
Author

@jeffkl It's working as expected. Thank you

@jeffkl
Copy link
Collaborator

jeffkl commented Nov 17, 2021

Thanks for reporting the issue, luckily the fix was easy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants