madskristensen / Tweakster

A Visual Studio extension
Apache License 2.0
240 stars 23 forks source link

'Save solution on build' when triggered from the command line #40

Open NoelAbrahams opened 3 years ago

NoelAbrahams commented 3 years ago

Is there any way to get this to run from the command line?

eg myCommandFile.cmd

@echo off

REM Locate the path to `msbuild`
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do (

  echo Save solution before build
   >>>> HERE >>>

   echo Building the solution...
   "%%i" -m -verbosity:quiet -nologo

   echo Complete
  exit /b !errorlevel!
)

I understand the difficulty since Visual Studio is a separate process to the command line.

The command above is actually bound to an 'External Tool' (tools menu) and then triggered by the user clicking on the menu item in VS.

The problem is when there are open files with unsaved changes, the command runs on the file persisted on disk ignoring the changes.

Is there any way to get Visual Studio to save the solution before build for this scenario? Perhaps an option on the 'External Tools' menu?

image

madskristensen commented 3 years ago

This is an MSBuild command and not one done in Visual Studio. I don't know what you are trying to achieve here. Do you wish to replace the regular build in VS with one you run on the command line instead?

NoelAbrahams commented 3 years ago

This is an MSBuild command and not one done in Visual Studio.

Yes, it is clearly an MSBuild script. The script is saved as a file. This file is triggered as an 'External Tool' as stated here:

The command above is actually bound to an 'External Tool' (tools menu) and then triggered by the user clicking on the menu item in VS.

Regarding this:

I don't know what you are trying to achieve here

The ultimate goal is the following:

I don't want to be running things from the command line. This build should be triggered from within Visual Studio. Creating a script and adding it as an 'External Tool' achieves this.

The only thing that is failing is that when there are files with unsaved changes, they are not saved when the build is run.

Is the problem clear enough?

madskristensen commented 3 years ago

yes, thanks

madskristensen commented 3 years ago

All feature requests to this extension must be backed by a real Visual Studio suggestion registered at Developer Community. Please create one and post the link back here.

NoelAbrahams commented 3 years ago

Done https://developercommunity.visualstudio.com/idea/1227402/allow-building-a-subset-of-projects.html