'Developers command prompt in Azure DevOps
We have a team Foundation Server setup on premise. This is Azure-devops but a local setup.
We have the ASP.Net code. The code base doesn't have a .sln file or a .csproj file for the MSBuild. To build the code Dev team runs Below command from developers command prompt for VS2017
aspnet_compiler -p "E:\project\Release\netCompile" -v / E:\project\Release\netdeploy -f
I cannot run this command from the command line as it is throwing an error saying
aspnet_compiler is not recognized as an internal command.
I tried to use the following command in command line to open the developers command prompt, followed by the aspnet_compiler command.
script: '%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"" amd64_x86'
This seems to work fine but then again the aspnet_compiler command exit with code 1.
Can I know how can I achieve this task in Azure DevOps
Solution 1:[1]
- task: CmdLine@2
inputs:
script: 'echo call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat"
> deploy_app_test.bat
echo aspnet_compiler -p "./" -v / ../build -f >> deploy_app_test.bat
echo aspnet_merge ../build -a -o app -xmldocs >> deploy_app_test.bat'
- task: BatchScript@1
inputs:
filename: "deploy_app_test.bat"
arguments:
I was able to bypass this by creating a batch file with Dev Command Prompt and running it through command line.
Solution 2:[2]
You can run VsDevCmd.bat
with "modifyEnvironment" set to true.
- task: BatchScript@1
inputs:
filename: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat'
arguments: '-arch=amd64'
modifyEnvironment: true
displayName: "Initialize Visual Studio Environment"
- script: # something that runs in the developer command prompt
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Phaneeth |
Solution 2 | Hadi Moshayedi |