I would like to avoid adding the generated JavaScript files to the git source control repository. Does the Azure Git Deploy support running addition commands to run the build before deploying the files?
5 Answers
Yes, you can run arbitrary logic using a custom deployment script. You'll need to either include the tools you need in your repo, or preferably download them as needed (to avoid commiting binaries).
6 Comments
For now you can generate a custom deployment script custom deployment script
Then edit the npm command to use the newer node.exe version (0.8.2) with the following command:
call "D:\Program Files (x86)\nodejs\0.8.2\node.exe" "D:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" install --production
2 Comments
Just in case somebody else is looking, this is what I needed to do to get this working.
First, I make sure that TypeScript is installed where the Kudu build server can reach it, by adding these lines somewhere towards the top of my deploy.cmd file:
call npm install typescript
IF %ERRORLEVEL% NEQ 0 (
echo Unable to install TypeScript
goto error
)
This places the Node-callable version of TypeScript in .\node_modules\.bin\tsc.cmd.
The batch file that actually performs the build (callable in various ways, but primarily as a post-build event) looks like this:
@echo off
if (%1%=="") goto settsc
cd %1%
:settsc
if exist ".\node_modules\.bin\tsc.cmd" (
set tsc=call ".\node_modules\.bin\tsc.cmd"
goto build
)
if exist "%ProgramFiles(x86)%\Microsoft Sdks\Typescript\0.9\tsc.exe" (
set tsc="%ProgramFiles(x86)%\Microsoft Sdks\Typescript\0.9\tsc.exe"
goto build
)
if exist "%ProgramFiles%\Microsoft Sdks\Typescript\0.9\tsc.exe" (
set tsc="%ProgramFiles%\Microsoft Sdks\Typescript\0.9\tsc.exe"
goto build
)
echo TypeScript compiler not found
exit 999
:build
echo Building TypeScript: Payboard.Site.js (using %tsc%)
%tsc% --sourcemap --out Scripts\Payboard\Payboard.Site.js @tsbuild_Site.txt
echo Building TypeScript: Payboard Widget (using %tsc%)
%tsc% --sourcemap --out Widget\v1.0\Payboard.js @tsbuild_Widget_v10.txt
echo Building TypeScript: App\Payboard.App.js (using %tsc%)
%tsc% --sourcemap --out App\Payboard.App.js @tsbuild_App.txt
Hope this helps someone else out.
Comments
And here is another option for a workaround that doesn't require custom deploy scripts, no batch files and only minimal changes to the project file.
The blog post with details is available at http://manfredlange.blogspot.co.nz/2014/01/aspnet-mvc-typescript-azure-website-and.html. The source code for the example project referred to in the blog post is available at https://bitbucket.org/ml_agileutilities/typescript-sample. There is a branch that reproduces the issue and there is a second branch that includes the workaround.
Please be aware that as far as I know Microsoft is working on a proper solution. At the time you are reading this the workaround may no longer be required.
Comments
Typescript can now be used without any scripting. Just make sure TypeScript works from VS, then it will also work in the Kudu build. Note that you may have TypeScript version clashes, see e.g. this question .