I'm trying to deploy an artifact from VSTS to an Azure App Service, using Deploy an Azure Web App step template in Octopus Deploy. The VSTS zip package will have a structure like the following:
\Content\C_C\a\1\s\Api{ProjectName\obj\Release\Package\PackageTmp
When I publish the zip file using MsDeploy.exe. It automatically only copy the folders & files inside the PackageTmp folder into the wwwroot folder. However, when I use the Octopus deploy, It copies all of the folder from Content\. Is there any way to make the Octopus deploy work like using MsDeploy.exe? I'd like to use the zip as is, so adding a Copy Files step or changing the PackageLocation in the VSTS build is not really an option.
Any help/suggestion is really appreciated.
Thank you.
To achieve the layout of the files as you describe, you will have to modify your build step. In the MSBuild arguments section on the build step, ensure you have the following parameters defined:
/p:WebPublishMethod=FileSystem /p:PackageLocation="$(build.artifactstagingdirectory)\\"
These two parameters will create the package in the directory specified by the PackageLocation parameter, and it should be in the format you expect.
In the step where you push the package to Octopus specify this directory as the Package Source.
There isn’t such setting to do it.
You can publish the web app with File System mode , then package the files through Package Application task.
Related
I wrote two azure pipelines. One pipeline build my app as a tool and publishes to a artifact feed.
My second pipeline runs that app from artifact feed. Problem is that my app does not see appsettings.json. When I tried to print current directory I saw that is root repo folder. How to solve this?
What have I tried is to set workingDirectory in task that run's tool as:
$(Build.BinariesDirectory)
$(Agent.BuildDirectory)
etc..
So, when I run tool locally and print current directory files i get all DLL's included. But on azure I get repo root.
Is my approach good or completely wrong?
Has anyone used Azure DevOps to deploy an Umbraco v8 application to Azure?
I can successfully deploy via Visual Studio, but Azure DevOps only seems to copy over all the dlls to the target, no views or anything, and a zip does not get generated.
If anyone has managed this could they share the steps they took please?
The steps I have in the pipeline are:
Build
Test
Deploy
Publish Symbols
Copy File to
Publish Artifact
What I did notice is that I need a publish profile to successfully publish from Visual Studio, however I cant see where a profile should be included in Devops, unless it should be in the build arguments?
My current build arguments:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\"
I'm using the Visual Studio Build task.
To straight up answer your question, yes MSBuild arguments make or break the deployment here.You can see mine in my screenshot. I took it from a production deployment that's successful for Umbraco.
So I can't see your actual pipeline, but from what I see you don't actually 'build' the application.
As in you have to use Nuget first, then restore the packages, then build the application. You don't need to copy anything (so you don't need a copy step), with the correct MS Build arguments it will build and copy to build.artifactstagingdirectory on its own. Then you need to have the appropriate release pipeline, but one thing at a time. The build steps I use are underneath. After the npm custom step is the actual building of the application.
P.S. Make sure that the appropriate files to run the application are included in the csproj, because that's where azure devops reads what to pick and build.
I'll assume that you're simply copying files onto a VM and that you have dealt with the deployment of your database / content.
If you want to copy all the files from your Visual Studio project you need to ensure that your MSBuild will copy them into the build/artifact directory.
In order to copy the files that you're missing you need to ensure that you have set the “Build Action” to “Copy to output directory” for example your views or pretty much anything that you'd code in App_Data. This is how you'd set the build action in VS: https://learn.microsoft.com/en-us/visualstudio/ide/build-actions?view=vs-2019
I'm very confused about how one of the build task currently works.
I have been using Grunt locally in VS-Code to minify a JS file. All seems to be working well. In Azure DevOps, as a Build Task, I am using the same package.json the minification takes place but on the agent VM:
D:\a\1\s\Build\Hello.js
Looking in my repo, this file does not exist. I am assuming that I need to copy the file and upload to my own repo. Does anyone know how I do this?
A build usually creates a build ** artifact** that gets copied to a drop location. You will use the build artifacts inside your release definitions to deploy the binaries / minified or optimized code to an environment.
You probably don't want/need to upload any file back to your repo.
See: What is Azure pipelines
I'm attempting to use VSTS to build and deploy my .net core Web API Web App Service.
It appears that previous versions of .net (including somewhat recent versions of .net core) created a zip file. The default configuration for an Azure App Service Deploy have the field Package or Folder set to $(System.DefaultWorkingDirectory)/**/*.zip by default. This was failing for me with the error No package found with specified pattern: D:\a\1\s\**\*.zip
I was able to get it to kind of succeed by changing the path to simply $(System.DefaultWorkingDirectory), but from the Azure console I can see that this deploys everything (not just the binaries)
I could add a trainload of questions following this, but I'll keep this specific.
P.s.> I already looked here: dotnet publish command is not creating zip file package for asp.net core web application project, but it appears to be a different problem
You can check Zip Published Projects option of .NET Core Publish task and specify output argument (--output $(build.artifactstagingdirectory)
Then the Web API project will be published and zipped to a package in the artifact directory, after that you can specify $(build.artifactstagingdirectory)/**/*.zip in Package or Folder input box if you deploy the app during the same build.
I am not fully understand the questions, but I can give your some suggestion points.
1. Clean Sources
On "Get Sources" step choose Clean -> true -> Sources and Output.
This will ensure cleaning all old code.
2. Create package
After build use "dotnet publish" step. In "Path to project(s)" as POC I recommend to set path to your project:
{Your Solution}/{Your Project}/{Your Project}.csproj
You don't need to add "$(System.DefaultWorkingDirectory)" it is automatically added to path your enter. This will create package.zip file.
3. Copy package
Use "Copy Files" step. For "Target Folder" choose $(build.artifactstagingdirectory). As pattern set "**/*.zip". This will ensure, that only package files will be used for deploy.
4. Deploy package
Use "Azure App Service Deploy". As "Package or Folder" choose one of
$(build.artifactstagingdirectory)/**/*.zip
$(build.artifactstagingdirectory)/{Your Solution}/{Your Project}/**/*.zip
Hope it helps.
I just installed VS2017 and I want to deploy specific .js files without deploying the whole project. When I try to upload a new deployment file, VS force me to publish the project. Is it possible to just add a deployment file without deploying? So I can use that deployment file to deploy singles .js files or html files.
EDIT
Lets say I want to deploy a project to a virtual directory on Azure. For example to domain.com/newapp. Using a deployment file, I would like to first edit the settings, how am I supposed to do that, if VS2017 deploys the project immediately after I pick the deployment file.