Running Grunt from Visual Studio post build event command line - visual-studio-2010

I've attempted to do this both in Visual Studio 2010 and Visual Studio 2012. If my Gruntfile.js file is in the root of my project I can run the "grunt" command from the post build event command line and it runs without a problem.
grunt or grunt.cmd
But if it's in a sub directory
$(ProjectDir)Public\grunt or $(ProjectDir)Public\grunt.cmd
It gives me this error
The command "c:\web\Public\grunt.cmd" exited with code 9009.
I've been researching this but I'm not finding any much help out there. I did find in the grunt documentation that I need to use "grunt.cmd" instead of just calling "grunt" but thats not helping me much.

What's happening is you're specifying an exact path for grunt, which doesn't actually reside at $(ProjectDir)Public\. When you're in that directory on a command prompt and type grunt, it executes because you've set your path environment variable to include the directory where grunt lives.
Luckily the post build commands in VS act like a command window, so you can put this in your post build commands:
CD $(ProjectDir)Public\
grunt
And that should work (assuming a default grunt task is defined).

If you had Visual Studio open and then:
Installed node package manager (npm) and grunt
Then tried to run pre/post build commands including grunt command.
The build will simply fail with the "exited with code 9009" message. (Meaning "I don't know what grunt command is")
To resolve this situation just close visual studio and reopen it (as #longda mentioned on his comment) and everything will work just fine.
I'm using VS 2013 Premium and latest version of npm/grunt.

You can run as post build using task runner as shown below.
Right click on the build --> bindings--> and then specify if you need it to run post or pre build

Somewhat related, I had a weird issue that xcopy would not run after grunt, running them as a single command fixed it:
cd $(SolutionDir)..\App
grunt release && xcopy "$(SolutionDir)..\App\release" "$(TargetDir)Content\" /Y /E /S

Related

Visual Studio saying null when try to run code

so basically i tried running code in visual studio but it says null and doesn't open command prompt and also says build failed (https://i.stack.imgur.com/Gi5GT.png)
how to run the code with no errors
If you have python downloaded, then set the python environment. Click on Add Environment. Then browse to in install location.
This will resolve your issue.
You should download python separately
Just go to https://www.python.org/downloads/ and get the latest python version, then restart VS
It should work, my friend had same problem and this solved it

How to build and run Xamarin.UWP application from command line?

How do I build and run a Xamarin.UWP application from the command line? I want it to be so that the app builds and runs the same way as the green run button in the Visual Studio 2019 GUI.
Additional notes:
I've tried opening the Visual Studio Developer Command Prompt and trying the following implementations.
msbuild -t:build "PATH_TO_PROJECT\SimTools.UWP.csproj"
Although when I run the executable that gets generated, it gives me this error:
as well as
Additionally, I've tried doing
msbuild -t:build "PATH_TO_PROJECT\SimTools.UWP.csproj" && msbuild -t:install "PATH_TO_PROJECT\SimTools.UWP.csproj"
And although it builds successfully, it says that there is no target for "install" and I do not know how to add that to the .csproj file as I've asked over at How do I add an "install" target to a Xamarin.UWP .csproj file?.

How to build Visual Studio Installer Project in Azure Devops Pipeline Hosted Agent

I have a Visual Studio setup project. Normally I use the Microsoft Visual Studio Installer Projects extension, and run an MSBuild Exec task with command line using devenv. This works on my dev box and my existing build machine. However I'm looking to migrate to a hosted pipeline agent using the VS2017 image.
I was hoping the installer extension might already be installed, so I tried my build and got an error:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.com" "D:\a\2\s\Source\Build..\WindowsFormsApp1\WindowsFormsApp1.sln" /Build "Debug" /Project "Setup1" /ProjectConfig "Debug" /Log
The operation could not be completed. The parameter is incorrect.
I tried adding the VSIX to my repo, and then issuing a command line install of the VSIX as such:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VSIXInstaller.exe" /a /quiet /log:MyTestApp.log D:\a\2\s\Source\Build\InstallerProjects.vsix
However that seems to block for about 10 minutes, and then fails with an error (I suspect the UI is blocking even though I used the /quiet arg to suppress the UI):
... exited with code -2146233088.
Is there any way to build a Visual Studio installer project using a MS-hosted pipeline agent?
How to build Visual Studio Installer Project in Azure Devops Pipeline Hosted Agent
AFAIK, I am afraid we could not build Visual Studio Installer Project in Azure Devops Pipeline Hosted Agent at this moment.
I encountered a similar issue two weeks ago, after a period of investigation, I started to try the same idea as you, using command line to install the Microsoft Visual Studio Installer Projects extension.
However, I got the timeout issue. I could not install that extension on the hosted agent. To test the reason for this, I use the same command lien to installed that extension on another local machine. Indeed, there is a UI window to confirm if you want to install this extension, even after I give the /admin parameter:
Check the options here.
Then I try to open the command line with Administrator and execute the same command line, it can successfully install that extension. So, I want to execute the command line in the Azure DevOps pipeline. But no success. Because we could not execute command line script as admin using Command Line Script task.
It seems we have to set our private agent.
Hope this helps.

Grunt JS Task Runner - Tasks directory not found, Task "vs-grunt-task-reader" not found - File path prefixed with /c$/

I've just started at a new company and we pulled all the code from source to my local computer. Everything runs fine, except the Task Runner Explorer is failing to run Gruntfile.js because it can't find vs-grunt-task-reader.js
Here's the error:
Failed to run "C:\Projects\DQ2 Application\deltaquestv2_frontend\DeltaQuest2\DeltaQuest2\DQ2-Client\Gruntfile.js"...
Then:
Tasks directory "\c$\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\TaskRunnerExplorer\Scripts" not found.
Warning: Task "vs-grunt-task-reader" not found.
And the command that fails:
cmd.exe /c grunt -b "C:\Projects\DQ2 Application\deltaquestv2_frontend\DeltaQuest2\DeltaQuest2\DQ2-Client" --gruntfile "C:\Projects\DQ2 Application\deltaquestv2_frontend\DeltaQuest2\DeltaQuest2\DQ2-Client\Gruntfile.js" --tasks "\c$\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\TaskRunnerExplorer\Scripts" vs-grunt-task-reader
When I run the command in cmd, I get the same message, but when I change the \c$to C:, it works runs successfully.
Is there a way to change the \c$ to C: within Visual Studio or the Grunt config?
Or is there any reason why the Grunt Task Runner runs fine on one computer and not mine?
Not sure if this makes any difference to this question, but if I run "\myComputerName\c$" it opens C: in explorer
I found a tutorial on setting up Grunt in Visual Studio 2015, and the first thing it says to do is: "Install Web Essential 2015 from Tools / Extensions and Updates".
Problem solved!
https://dvoituron.com/2015/07/15/grunt-and-bower-in-visual-studio-2015/

Gulp:Error while running from Visual Studio Post Build Event

I am trying to run gulp default task on VS 2010 Post Build Event
like
cd $(ProjectDir)
gulp
But VS Freezes when i click on Build Solution while same is working fine on command window.
Anyone faced this issue earlier or help me in this?
Edit: Visual Studio 2015 now has full support for gulp, with hooks to make it much easier to integrate.
Old answer: This is because gulp-watch is a long-running process; it's watching files for changes, and so does not exit.
Perhaps on your post-build task, you could use something like cmdow to fire off the task in a separate process, which should let the build "finish" properly.
Try using powershell start-process gulp as your command line. You may add a specific task too: powershell start-process gulp mytask

Resources