Deploy the Gulp Build Folder To Azure from Visual Studio Team Services - azure

I just started using VSO for one of my project. I have created the built definition and the built was successful. When I tried to create the release definition for that built its failing by throwing the error
System.Management.Automation.RuntimeException: No files were found to deploy with search pattern C:\a\858bddd5b\**\*.zip
Its expecting .zip files. Since I need to deploy the distributed folder created by gulp build, I have given the Web Deploy Package path as
$(System.DefaultWorkingDirectory)/{built name}
Any help is really appreciated

You should add a build step to create an archive with .zip extension for the output folder of the gulp step. Your steps should look like
VSO/VSTS build has a task available with Archive files to achieve the same.
Alternatively, if the standard Archive files step doesn't work for you, you can use a powershell step. The powershell command will look like the following.
[io.compression.zipfile]::CreateFromDirectory($Source, $Destination)
Source should be all the files/folders from gulp output you wish to deploy
Destination here should correspond to input for the webdeploy/ WebApp deployment step.

You can also use this extension to create a ZIP file. I used it for a situation similar to yours:
https://marketplace.visualstudio.com/items?itemName=trackyon.trackyonadvantage

"Azure Web App Deployment" task requires a web deploy zip package. You can either add one more task to create a zip package for the build output as other two answers indicated or add some code in your "gulpfile.js" to generate a zip package during the gulp build and then publish the zip package to artifact.
If you don't want to create a zip package for the build output, then you can use FTP Uploader task to deploy the build to Azure Web App via FTP Deploy.

You can create a zip file with PowerShell, assuming you're running on a Windows agent.
Command Line task
Command: powershell
Arguments: -Command "&{Add-Type -assembly 'system.io.compression.filesystem'; [io.compression.zipfile]::CreateFromDirectory('$(Build.StagingDirectory)\Zip', '$(Build.StagingDirectory)\$(BuildConfiguration)Deploy.zip')}"
Obviously, replace $(Build.StagingDirectory)\Zip with whatever folder you want zipped up and $(Build.StagingDirectory)\$(BuildConfiguration)Deploy.zip with whatever you want the file named.

Related

Deploying a Vue app to Azure App Services with Azure Pipelines/releases

I'm trying to set up CI/CD with Azure pipelines to automatically deploy a frontend vue application, but am having trouble with deploying my frontend application from it.
When deploying manually from the VS Code IDE it works fine, with the /home/site/wwwroot looking as expected in the kudu file explorer:
However when it's deploying from Azure Pipelines, it seems that the zip file remains zipped and is stored in another directory within /home/site/wwwroot/Package (e.g /home/site/wwwroot/Client/.zip), resulting in the application being unable to
This is what it looks like in the kudu powershell debugger:
My pipeline and release is pretty standard. The steps are:
Uses Node 16.x
Downloads a .env file
Copies the .env file to the directory (/client) the application is in.
runs npm install
runs npm run build
archives the dist directory that is generated from the run build command
Publishes the archived dist folder as an artifact
An Azure release is then created and deploys the artifact to the correct Azure App Service. Currently the deployment method is set to default, although I have tried each of the different deployment methods (Web deploy, Zip deploy, and Run from package) but none have worked so far.
I've downloaded the resulting zip file from the pipeline deployment, unzipped and manually deployed (using VS Code) the dist folder within which was successful, so I'm quite sure that the pipeline part of the process which installs, builds, and packages the application is working as expected, but something is going wrong during deployment.
If anyone has any ideas of what the error may be, or is able to offer any help/sugestions, it would be greatly appreciated.
Thank you.
Ensure that the archive job option for "prepend root folder name to archive paths" is disabled in the pipeline.
Also ensure the Package or folder route in the release's deploy job is correct. It should be something like:
$(System.DefaultWorkingDirectory)/______ClientPipeline/ArtifactName/*zip

Azure run from package (.zip) with parameters

I've found a way to run a dotnet app from a zip file.
My .zip only contains the build output of a regular dotnet build (an .exe and several .dlls).
My task is to pass an argument to the .exe file. I don't see any options neither on Azure Portal, nor on Kudu. Is there a way to run an Azure Web App from package with parameters? Thanks.

Azure Devops - Build project, delete some files and zip a folder

I'm starting on Azure Devops.
With Azure Devops, how can I delete some files after the solution build and before generate a zip file, but all this in the same step?
In the image step, do the solution build and generate a zip with the package, ready to deploy, but I need delete some files inside this zip file.
MSBuild process print screen with arguments:
Zip file with all files to be deployed in the server and the zip that I need delete some files:
Maybe I will need unzip the package, delete the files and zip the package?
This MSBuild task will build project with MSBuild. And reviewing this doc: MSBuild Properties we find that currently there is no such argument implementing this feature.
In the meanwhile, we find this doc guides how to exclude Files and Folders from a Web Package.

Compile directory in Azure DevOps Repos and save the results somewhere

Let’s say I have a directory structure like this in an Azure DevOps repo:
Main/
- A/
- *.csproj
- B/
- *.csproj
- C/
- *.csproj
Each subfolder has a .csproj file. I want to compile the Main/A/ folder and save the build results (artifacts?) somewhere, be it a folder or something else. How do I tell Azure to build that precise Main/A/*.csproj file and do I need to use /p:OutputPath inside the VSBuild#1 task, or do I need to use some other Azure task?
How do I tell Azure to build that precise Main/A/*.csproj file and do
I need to use /p:OutputPath inside the VSBuild#1 task
If you're using classic UI, you need to unlink the default solution:
And then choose the A project by the browse option:
If you're using Yaml format, you should use something like solution: A/A.csproj to specify which project to build.
Note:
Since now we're building single project instead of whole solution, we should use Project Configuration instead of Solution Configuration. any cpu is Solution Platform instead of Project Platform(AnyCPU). So we should make sure we're building single project with AnyCPU if we want to build one project with this setting.
If you got error The OutputPath property is not set for project 'A.csproj', that indicates you should use valid project configuration. In your case, if you're using any cpu, change it to AnyCPU.
In addition:
1.To publish the build results as build artifacts for further use. You can use Copy Files task and Publish Build Artifacts task like this:
Copy Files Task.
Publish Build Artifacts
Then you can download the Test.zip in Summary tab from build log page. Also, you can use this artifact in release pipeline by using download artifacts task.
Check this, if you're trying build code project instead of whole solution. You can consider MSBuild Task. They(Msbuild task,VS Build task) both calls msbuild.exe to do the build job.
Hope all above helps :)

Adding cache worker role causes build error

I have an Azure cloud service project to which I am adding a cache worker role. While local build goes through fine, I get the following error on my server builds :
CloudServices38 : The entrypoint dll is not defined for worker role <cachename>
What is wrong? How do I fix this?
Make sure all the Azure DLLs are marked Copy Local = True in the properties window. Also, package your projects, then unzip them. Once you build the package, you will have a file YourProject.cspkg. Change the extension from .cspkg to .zip and extract the files. In these files you should see a file with the extension .cssx YourProject_.cssx. Change the extension from .cssx to .zip and extract again. You project that is deployed will be in the folder YourProject\sitesroot\0 - verufy all the files you are expecting (i.e. content and everything that is in the bin directory on your local build.
You need to run a Build and a Publish separately. I ran into the same problem on my project and this fixed it.
1) Visual Studio Build (or MSBuild) action with arguments /t:Build (clean here)
2) Visual Studio Build (or MSBuild) action with arguments /t:Publish (do not clean here)
Note: I had to run these actions separately (not /Build;Publish) otherwise I got an error about the cloud service entry point.
Pieced this together from this question and from here and here.

Resources