arcade icon indicating copy to clipboard operation
arcade copied to clipboard

Add `-vs` and `-vscode` to build scripts

Open Youssef1313 opened this issue 7 months ago • 8 comments

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.

Youssef1313 avatar May 20 '25 09:05 Youssef1313

It was originally copied from runtime repo if I recall correctly

Evangelink avatar May 20 '25 10:05 Evangelink

Looking at https://github.com/dotnet/runtime/blob/b04d40e55b3fcaf74dcf0672a2009ec173bcd002/eng/build.ps1#L170-L292, the -vs switch does the following:

  1. Finds the sln to invoke (just a shortcut to not need to supply the full path)
  2. Restores the .NET SDK if it isn't available locally or globally
  3. Sets a few non runtime specific env vars to tell VS to use that SDK
  4. 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.

ViktorHofer avatar May 27 '25 08:05 ViktorHofer

cc @jaredpar @agocke for thoughts

ViktorHofer avatar May 27 '25 08:05 ViktorHofer

Now that we have local SDK support in global.json, are these type of scripts even needed anymore?

jaredpar avatar May 27 '25 17:05 jaredpar

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)

ViktorHofer avatar May 27 '25 17:05 ViktorHofer

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 in global.json completed
  • eng/common/dotnet.sh/cmd: this lets you put eng/common/dotnet.sh run calls in scripts. Under the hood it ensures that the .NET SDK is intalled and then uses the dotnet from it to run the arguments.

jaredpar avatar May 27 '25 17:05 jaredpar

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?

ViktorHofer avatar May 27 '25 18:05 ViktorHofer

Yep

jaredpar avatar May 28 '25 00:05 jaredpar