.net WebDeploy is there any way to run command/script on the target machine after deploy - webdeploy

I have and .net/angular2 application, I'm publishing with WebDeploy.
But when the publish finish I wanna run some command on the target machine like
npm install
npm run tsc
There is a way to do that?

You should be able to use the postSync argument:
msdeploy -verb:sync -source:contentPath="C:\Test1" -dest:contentPath="C:\Test2" -postSync:runcommand="c:\MyBatchFile.bat"
https://technet.microsoft.com/en-us/library/dd569089(v=ws.10).aspx

Related

How to connect npm with NuGet packages?

I've started a Fable project using a starter template. In order to run it, I was previous successfully using npm run build.
Using Visual Studio, I installed some NuGet packages (Serilog, Dapper) but now when I call npm start, the terminal complains that the NuGet packages calls cannot be resolved:
ERROR in ./src/Project.App/App.fs
Module Error (from ./node_modules/fable-loader/index.js):
C:/Users/markr/git-repos/SampleProject/src/SampleProject.App/App.fs(95,12): (95,47) error FABLE: Cannot resolve Serilog.Log.Error
# ./src/SampleProject.App/SampleProject.App.fsproj 1:0-25 1:0-25
It makes this same complaint for all NuGet package calls. How do I make it so that I can run npm run build while using NuGet packages?
It turns out what I'm trying to do is impossible. Using SAFE architecture now to be able to properly implement a NuGet side (server) and an npm side (client)

Change Task Runner Explorer command

In Visual Studio 2019 I have installed the extension call NPM Task Runner.
When I run a the build command the output is:
cmd.exe /c npm run build --color=always
How do I change that to:
npm run build --color=always
Because when I run the first one I get an error.
How can I fix the error or change the command.
P.S.: When I run the command like this npm run build --color=always in the console it works.
This fixed the problem for me.
Tools > Options > Projects and Solutions > Web Package Management >
External Web Tools
Move the $(PATH) entry to the 2nd position in the list by using the
up arrow button.
Post: Executes wrong version of nodejs

npm install when deploy Octopus

I need to create node_modules in the root app when deploy new version using Octopus
How can I create a run script using a new octopus step? I try:
npm install
But I get error when execute the script step
'The remote script failed with exit code 1'
Any ideas?
Your build system should be handling that for you. The node_modules directory should then be included in your application package, but ideally, this should also be bundled to reduce the number of files that your application is dependant on.
If you do need to run this as part of a deployment, then you would need NodeJS and npm installed on the server that is executing the deployment step (either the Octopus server itself or a worker instance if using workers).
For more information check out this blog post

Missing node_modules when deploying AngularJS2 application to Bluemix

We're trying to deploy an AngularJS2 application to bluemix but we're missing the folder "node_modules" after the application was deployed to the server. We're using npm to build the application.
I found the following post that is mentioning the problem: (https://developer.ibm.com/answers/questions/181207/npm-install-within-subdirectory-not-creating-node.html)
My question would now be: what's the recommended best practice?
I believe you are installing the node modules using npm install, you also should save those module in your package.json file which you can do that by npm install --save.
The recommended best practice would be to Setup a Build Pipeline.
There could be 3 stages or more:
Build Stage: It builds the app so doing things like npm install there so your folder node_modules gets created for you.
Test Stage: Tests the app so doing things like npm test would run all the tests in your app
Deploy Stage: Once build and deploy stage runs successfully, Deploy will actually deploy the app to the Bluemix domain.

running bower from TeamCity (Windows)

I've got a set of build steps in a project (Team City 9.0c)
One of them is running bower install which is a simple command line execution with no parameters.
Bower is installed on the system (I can run it just fine from the command prompt on the machine) but I get the following error
[10:47:35][Step 2/7] Starting: D:\TeamCity\buildAgent\temp\agentTmp\custom_script8385462966123630321.cmd
[10:47:35][Step 2/7] in directory: D:\TeamCity\buildAgent\work\5d43cd6017ab83d4\website\Amaze.Web
[10:47:37][Step 2/7] 'bower' is not recognized as an internal or external command,
[10:47:37][Step 2/7] operable program or batch file.
[10:47:37][Step 2/7] Process exited with code 1
[10:47:37][Step 2/7] Step Bower (Command Line) failed
I've seen this before where PATH is not set to the location of the npm binaries in c:\users\xxxx\roaming\... so the TC user cannot find them, however PATH is correct.
Both npm and grunt work successfully. What could be causing this?
Is the path variable defined a user variable? If so, it should be a system variable which will be used by the TeamCity process.
You haven't written which accounts the build agent runs as.
I had a similar problem and my build agent was running using Local System. I had to create a dedicated windows user account for the teamcity build agent, in the build script I added
npm install -g bower
set path=%path%;c:\path_to_bower_for_this_user;