Reputation: 3651
I would like to execute the "Post-build" event without building the project. is there an option to do so somehow?
Upvotes: 4
Views: 1989
Reputation: 14233
I would recommend putting the commands into a batch file and simply running THAT in your Post Build Events field.
You can add it to your solution and then from Solution Explorer, right click, "Open With", and add a new item called:
This will allow you to run Batch files from Solution Explorer in the future. More details here.
Bat File Solution 1
Either pass in the path to run from, or rely on %SolutionPath% (which is an env var that is provided when you run a bat file from Visual Studio). So this method is doing some directory sniffing. (note, solution 2 below is probably better - simpler for sure)
@echo off
if not [%1]==[] (set "ProjectDir=%1")
if not [%SolutionPath%]==[] (set "ProjectDir=%SolutionPath%\ProjectSubDirectory)
if [%ProjectDir%]==[] (
echo Error, no Solution Path env var or ProjectDir provided
exit /b
goto :eof
)
cd /d %ProjectDir%
ng build
Your post build events would then just run $(ProjectDir)\MyBatchFile.bat "$(ProjectDir)"
Bat File Solution 2
Run in directory relative to location of batch file (a simpler solution).
@echo off
pushd "%dp0"
ng build
popd
In this case your post build event would simply be: $(ProjectDir)\MyBatchFile.bat
and it would run in that same directory. I would recommend this approach for simplicity.
Pushd and popd are similar to "CD" except it's a stack that you can pop out of. So popd will return you to your original directory. %dp0
is the directory of the currently executing bat file.
Upvotes: 2
Reputation: 25351
Launch the Developer Command Prompt:
Then copy the lines from your Visual Studio:
$(ProjectDir)
with the actual path to your project.Upvotes: 3