-
Notifications
You must be signed in to change notification settings - Fork 78
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
Feature request: Include full solution file header to enable Microsoft Visual Studio Version Selector
to pick correctly
#308
Comments
I looked into this a while back but couldn't figure out a good way of determining the version of Visual Studio. If SlnGen knows which I propose that if SlnGen is running in a terminal where |
Thanks @jeffkl. I'm a bit confused by some of your statements, so forgive me if I misunderstood something. Is SlnGen locating the Visual Studio Version Selector and executing it or is it just invoking the I rarely have With the Visual Studio Version Selector seems to be the right solution, in my opinion. We just need to enable it to do its job by filling in the right information in the file header. Getting the "right" version information is the tricky part. I don't know if something similar to what I did in SlnUp would be appropriate or not, but might be worth taking a look at. I essentially generate a json file with all the release versions of VS from the docs that SlnUp uses to resolve simple human friendly VS versions to VS build versions (2022 -> 17.0.31912.275, 2019 -> 16.11.31911.196, 16.8 -> 16.8.31019.35). I could have queried the docs at runtime, but didn't want the tool to be left broken if the docs are down or change format. SlnUp is very new and I haven't really had enough time to live with the maintenance or rough edges of such a convenience yet. I literally just recently created it to workaround this issue in SlnGen. It has also been convenient as I update non-generated Perhaps SlnGen doesn't need to be as thorough as I was in SlnUp. Maybe a simple Another, slightly more sophisticated version could be a |
I think the main thing to keep in mind is that SlnGen must load and evaluate the projects with MSBuild APIs in order to determine the transitive closure of projects and their dependencies. To do this, it must find MSBuild. On Windows machines, it currently looks for MSBuild.exe on the The behavior of launching the SLN file itself seems to be too problematic. As you've seen, some machines have Visual Studio 2019 associated with the The latest version, 8.0.0, doesn't use "shell execute" anymore. It finds a Visual Studio for the MSBuild that was used and if one is not found then an error is logged. As a backup, users can specify the full path to |
But, again, that only applies if you're always relying on SlnGen to launch the .sln, right? Could we get the version of devenv to stamp into the .sln that gets generated? |
Given the changes in 8.0.0, it doesn't sounds like what i'm asking for is going to fit with the direction you're headed. I'll stick with my workaround and not rely on slngen to launch the solution for me. Essentially: & dotnet slngen **\*.csproj --solutionfile:$solutionFilePath --launch:false --ignoreMainProject
& dotnet slnup 2022 --path $solutionFilePath
if ($Launch) {
Write-Host 'Launching Visual Studio...'
& $solutionFilePath
} |
It sounds like the only good solution is to pass in the version you want to use? If you want SlnGen to figure out the version for you, then it needs to know which VS instance to use which sounds like is exactly the problem? There is a command-line argument to tell it which I think I need to understand your workflow more. You never want SlnGen to launch Visual Studio for you but you must have the version embedded in the generated solution so that later on, when someone opens the solution manually, the correct Visual Studio instance is used? Do you not use the Visual Studio Developer Command Prompt? I am not opposed to writing a version to the solution file as an opt-in feature. SlnGen would still need to know which Visual Studio instance to use when determining the version, unless you want to have the user pass in the version every time. In my opinion, its a better user experience if everything "just works". I've tried to make SlnGen be as straightforward as possible by having it determine the build environment automatically so most users can just run it. When you're using Visual Studio and want to do things from the command-line, the best experience is to use the Developer Command Prompt for that instance. If you have multiple instances of Visual Studio, each Developer Command Prompt has the corresponding instance of Things get more complicated if you want to use a different terminal like git bash. In this case, I'm assuming you're relying on the fact that SlnGen has to work within the constraints of the Microsoft Developer Ecosystem and I want it to be as easy to use as possible. I fully realize that its "magic" is not going to be correct in every case. I'm also very open to adding new features, even if they are have low demand. I guess I'm wondering if your developer workflow could be adjusted to make things work as you want, or if the tooling should adapt to your needs. I'm very interested to learn more if you don't mind sharing, I really appreciate the discussion. |
I do not use the Visual Studio Developer Command Prompt. I understand the complexities between what the .NET SDK and msbuild.exe and appreciate your diligence to accommodate the various options. I was hoping that by adding version information to the
I agree with you, which was an option I suggested as well:
For the sake of simplicity, let's consider a pure .NET project. I work in a team of people with varying different preferences and skillsets (like many others). In one particular case, some don't want a solution file checked into the project at all and prefer a
In my particular case, I don't expect I think there are various options here, but to be specific, here are a few that I think make sense to start with:
|
a224cf8 indicates a strong preference for |
Adds command-line argument `--vsversion`. When present, the version of Visual Studio used to launch the solution is included in the solution file header. If a value is specified, that version is used instead. Fixes #308
Okay I've added a command-line argument, |
The solution file generated lacks the full file header for a solution file (see here).
The solution file header that gets generated is essentially just the file format version:
It would be great if it contained a full file header to empower the
Microsoft Visual Studio Version Selector
to pick the right version to launch when multiple version of Visual Studio are installed.The full header is expected to look like:
Even better, it would be great if
SlnGen
took a parameter instructing which Visual Studio version to include in the file header.To workaround this very issue, I wrote a new SlnUp tool to update a solution file header with Visual Studio version information. However, this means I have to skip launching the solution using
SlnGen
so that I can runslnup 2022
against the generated solution file before launching the solution file myself. This allows theMicrosoft Visual Studio Version Selector
to launch the solution file using Visual Studio 2022 when multiple versions are installed.The text was updated successfully, but these errors were encountered: