Add `-vs` and `-vscode` to build scripts
In microsoft/testfx, we have -vs as part of our build.ps1:
https://github.com/microsoft/testfx/blob/9f043c6725409d3acc9871983460cbf8a669c6c9/eng/build.ps1#L36-L61
And then we have open-vs.cmd in repo root:
https://github.com/microsoft/testfx/blob/main/open-vs.cmd
We are also adding open-code.cmd in https://github.com/microsoft/testfx/pull/5592
I suggest adding these in Arcade so that they are available for all repos under eng/common, then individual repos can add simple wrappers in repo root.
It was originally copied from runtime repo if I recall correctly
Looking at https://github.com/dotnet/runtime/blob/b04d40e55b3fcaf74dcf0672a2009ec173bcd002/eng/build.ps1#L170-L292, the -vs switch does the following:
- Finds the sln to invoke (just a shortcut to not need to supply the full path)
- Restores the .NET SDK if it isn't available locally or globally
- Sets a few non runtime specific env vars to tell VS to use that SDK
- Sets a few runtime specific env vars
For 2) you would need to invoke a restore script first, i.e. Restore.cmd that downloads the .NET SDK. This step can be skipped if a matching .NET SDK is already installed globally.
For 3) we now have a product feature that tells the .NET host (and therefore also VS) to use the repo local .NET SDK if it exists: https://learn.microsoft.com/en-us/dotnet/core/tools/global-json#paths
1) and 4) are very runtime specific and shouldn't matter for this discussion.
cc @jaredpar @agocke for thoughts
Now that we have local SDK support in global.json, are these type of scripts even needed anymore?
See my above comment that describes what the scripts are doing. Local sdk support via paths in global.json covers point 3 but SDK acquisition still remains an issue (point 2)
I do think that we should address (2) in arcade. The ideal is almost that arcade adds four files:
-
eng/common/ensure-dotnet.sh/cmd: this just ensures that the acquisition of the dotnet described inglobal.jsoncompleted -
eng/common/dotnet.sh/cmd: this lets you puteng/common/dotnet.sh runcalls in scripts. Under the hood it ensures that the .NET SDK is intalled and then uses thedotnetfrom it to run the arguments.
Yes I agree. We have an equivalent to that in runtime: https://github.com/dotnet/runtime/blob/main/dotnet.sh, just with one script instead of two. I'm not sure if that addresses the scenario highlighted here though. People are asking for an easy way to install the SDK and use it inside VS, ideally via a single command.
With what you describe the flow would look like:
git clone https://github.com/dotnet/x && cd x
./eng/common/dotnet.sh # without args to just download the SDK
./x.slnx
Is that what you imagined?
Yep