I've got an Azure Resource Group-project (.deployproj) in Visual Studio which deploys fine. It is containing a DSC.ps1 file and a CustomScripts.ps1 file which is referenced by the template.json.
I want to deploy this project from TeamCity, but I can't find the way to build the project. During deploy Visual Studio outputs:
11:01:21 - Build started.
11:01:21 - Project "AzureResources.deployproj" (StageArtifacts target(s)):
11:01:21 - Project "AzureResources.deployproj" (ContentFilesProjectOutputGroup target(s)):
11:01:21 - Done building project "ESS.AzureResources.deployproj".
11:01:21 - Done building project "ESS.AzureResources.deployproj".
It seems it puts the DSC.ps1 file inside a zip-archive together with some dependencies before it runs the Deploy-AzureResourceGroup.ps1 which in turns does the deploy. The output of the build is put in bin/Debug/staging.
How can I perform the build from TeamCity/command line? Through msbuild?
I don't think the .deployproj has a deploy action, only build. To deploy you'd need an additional step in TeamCity to invoke the Deploy-AzureResourceGroup.ps1 and point it to the build output.
Related
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 :)
My repository contains an Asp.Net app, and a React app in seperate folder. I need to do a deployment to an Azure App service from a VSTS release.
Repository Root
MyAspNetApp
MyReactApp
The Asp.Net application is an MVC application. If it detects you on mobile it servers up the react app.
The react app is built using WebPack. When you do a production build, it copies the output into a folder called 'app' in the MyAspNetApp project. The production build can be run via 'npm run build-prod'.
When I was doing git deployments (kudu), I just added a command to the deploy.cmd to call 'npm install' and 'npm run build-prod'. Then another command to copy those files to the root of the deployment directory ('wwwroot').
Now that I am using VSTS to build and deploy (separate steps), I can't figure out how to get that 'app folder into wwwroot. In a build step I tried taking the stuff from the 'app' folder and putting it in an artifact called 'mobile'. Then in a deployment step, using a 'Copy Files' step to copy the 'mobile' artifact to $(build.artifactstagingdirectory)/app, but they don't show up in wwwroot on azure.
What am I missing here?
edit: cross posted here in MS VS Community site in hopes of getting a response. I will update this post if I get an answer there.
With Azure App Service Deploy task, if you check Publish using Web Deploy option, you need to put all necessary files in a zip file and specify this file in Package or folder input box.
You also can uncheck Publish using Web Deploy option and specify the root folder path of app.
Refer to these steps to do it:
Publish MVC application with File System publish method through Visual Studio build task
Run NPM commands to build React app through NPM task
Copy react app’s built files to necessary folder of MVC app deployed folder
(optional) Zip folder through Archive Files if you want to publish using web deploy
Add Azure App Service Deploy task (can be in release) and specify package or folder.
I want to deploy my .Net project from GitHub repository to the azure server.
In Deployment options I am getting Building failed error.
Here are screen shots of my Deployment details and Logs
1- Deployment Details:
2- Activity Log:
According to your description and logs, I found you have error in MSbuild step.
The error shows some files not found in your project. I suggest you could exclude the related files in the csproj file or make sure the related files is in your project.
Besides, I suggest you could firstly clone the project to your local and test it , make sure the project could build well without any error then publish to the GitHub and deploy to the azure.
Update:
I also write a test demo on my computer and I reproduce your error.
Error image:
I think in your project you have inclued the bin and obj folder into your project and then you push the project to the github.
Like below:
After you push the project to the github, the csporj file will include all the bin and obj references.
Like below:
This is the reason about your MSBuild fail.
So I suggest you uninclude all the bin and obj folder in the local and push to the github again. Then it will work well.
Azure looks in your site/repository/packages folder for all the packages your app uses. By looking through it you will find that visual studio doesn't deploy all of the files from your local packages folder to the azure one. MSBuild needs these files when you push to git and trigger a build. Ftp into your azure site and look for the packages folder. Upload every missing file (dll) from your local folder to the azure one. This worked for me and now I can trigger a build and deployment from bitbucket to azure app service upon a push.
Additionally, if you have other projects in your VS solution and you are using VS to build those projects and then put the dll into your main projects bin folder, that will cause a missing file error also. I create a folder in my packages folder and link the dll to my main folder from there. That way when you perform the fix above, the file needed by your main project is in the packages folder also.
I hope this helps!
I created a new ASP.Net core project and set it up in source control which publishes to Azure when I do a check-in. I was able to get everything setup correctly and it was working fine.
However, I then added a class library project to the solution and now instead of publishing my website project the MSBuild task is attempting to publish my class library which of course fails.
The line in the deployment command is:
"%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\MySolution.sln" /nologo /verbosity:m /p:deployOnBuild=True;AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false;publishUrl="%DEPLOYMENT_TEMP%"
And when that runs it first builds the models project which is fine:
D:\Program Files (x86)\dotnet\dotnet.exe build "D:\home\site\repository\MySolution.Models" --configuration Release --no-dependencies
But then it attempts to publish that project as well:
D:\Program Files (x86)\dotnet\dotnet.exe publish "D:\home\site\repository\MySolution.Models" --output "D:\local\Temp\PublishTemp\MySolution.Models71" --configuration Release --no-build
D:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(149,5): error : Can not find runtime target for framework '.NETStandard,Version=v1.6' compatible with one of the target runtimes: 'win8-x86, win7-x86'. Possible causes: [D:\home\site\repository\MySolution.Models\MySolution.Models.xproj]
Which is the wrong project (it should be the web project). I can't seem to find any files that contain the settings for this or the setting in the solution file itself.
What do I need to do for this to publish the correct project?
I was able to solve this by doing it in two steps.
First remove the deployOnBuild=True and the publishUrl=[snip] from the msbuild command. This means this step will build the project but doesn't do any publishing.
Next add a new step that does the publish.
To do this I first created a new variable to hold the location of the dotnet.exe:
IF DEFINED DOTNET_PATH goto DotNetPathDefined
SET DOTNET_PATH=%ProgramFiles(x86)%\dotnet\dotnet.exe
:DotNetPathDefined
Then add the following to do the publish of the web project:
call :ExecuteCmd "%DOTNET_PATH%" publish "%DEPLOYMENT_SOURCE%\MySolution.Web" --framework netcoreapp1.0 --output "%DEPLOYMENT_TEMP%" --configuration Release --no-build
IF !ERRORLEVEL! NEQ 0 goto error
This then publishes all the files to the deployment temp folder which then get deployed using the KuduSync step.
I have a teamcity (4.something) install that creates .wsp file for deployment to sharepoint. Currently I have to copy the wsp out of the build artifacts directory and into a little deploy folder I have created. In the folder I run a .bat that deploys the new .wsp to our test server.
What steps can I take to automate this?
Either copy the .bat into the artifacts folder and update the paths etc or copy from the artifacts folder into the 'deploy' folder and run the .bat from there.
I am a neophyte when it comes to the intricacies (or basics!) of MSBuild and the like... so hand holding is appreciated!
In more recent versions of TeamCity...
In the build definition you can identify artifacts which can be copied/zipped. Artifacts can then be downloaded manually or referenced from another build (Artifact Dependency).
You can setup a 'build configuration' to do your deployment directly from artifacts produced by your ci build.
Create a build to do your deployment
Build Step
Run: Executable with parameters
Command executable: .bat file (make sure it as part of the ci build artifacts generated)
Command parameters: whatever parameters your patch files needs
Dependencies
Add New Artifact dependency
Depend on: select the ci build you want to deploy
GetArtifacts from: Last successful build
Artifact rules: +:**/*.*
So, given artifacts (like your batch file) are in the CI build... You now have a 'deploy' build. When you run it (manually or setup a Build Trigger) it will copy all the CI build artifacts to it's working directory (Artifact Dependency) and then run your batch file to do the deployment.
Pretty slick.
note: just make sure that the account running the TeamCity BuildAgent has permissions to do all the deployment stuff.
Hope this helps somebody as it took me a while to sort this out ;)
I've done this by creating a nant task, and then having TeamCity execute the nant task. It's more of a pain than it should be. You should be able to do the same as a post-build event with MSBuild.