I'm tasked to automate the deployment of multiple, related ASP.NET 4.8 projects to Azure WebApps. The solution contains multiple projects, some of which represent virtual applications in the resulting WebApp and get deployed to different sub directories:
Project 1 -> site\wwwroot
Project 2 -> site\app1
Project 3 -> site\app2
etc.
Until now the solution was published using Visual Studios publishing functionality (right-click -> publish) and publishing profiles.
At first I thought that I could easily publish the solution using msbuild from commandline like this:
msbuild project1.csproj /p:DeployOnBuild=true /p:PublishProfile="PathToPubxml" /p:Password="SecretPassword"
Several attempts were made to get this to work but either there were errors or the separate projects were deployed to the same directory, I cannot even recall every single error we got trying out all kinds of possible solutions.
The easiest way would be to just execute devenv.exe with some parameter to trigger the publish functionality of Visual Studio that seems to work with this project setup but I couldn't find any commandline parameter to do this yet.
Is there any way to do this?
Related
There is a Visual Studio solution that has multiple web application projects. All of them are to be published to a common folder - D:\inetpub\wwwroot\FirstSite.
Each project has a publish profile Local.pubxml which imports settings from a global publishsettings.xml, and I use the One-Click Publish feature to publish each project.
Now, I would like to automate this process, which will Rebuild the solution and on success, publish all the projects to the target folder.
I have managed to create a Console application using C#, which can build all the projects in a solution. But, unfortunately could only go that far, as I'm unable to figure out how to get started about the publishing.
I'm not looking for setting up a build server. Just want to save time publishing projects to local folders.
Can we achieve this in a console application, by passing parameters like 'solution path' & 'target folder path', so that it can work for any such solution with multiple projects.
If not, are there any simple tools for this.
When you invoke msbuild for the solution build, you can pass
/p:DeployOnBuild=true /p:PublishProfile=Local /p:SkipInvalidConfigurations=true
which will publish each project with the Local profile for you
Developers use the Visual Studio (VS) GUI to develop their solutions and get their projects all building using a solution file (.SLN). The build teams using vNext then have to automate those builds using MSBuild instead of devenv.exe (the Visual Studio executable file). This is a serious and chronic problem because not only is MSBuild incapable of building several project types, but the build order is defined in a completely different, and complex, way.
Some Microsoft advice (https://learn.microsoft.com/en-us/archive/blogs/msbuild/incorrect-solution-build-ordering-when-using-msbuild-exe) is to switch to explicit dependencies in each .*proj file and remove all dependency specifications in the .SLN file. This sounds like a person who has never worked in a relatively powerless build team trying to get development teams to:
do a lot of what they perceive as time-wasting extra work and to
change how they do things
What build teams need is a way to automate whatever VS allows dev teams to build. If VS is given a SLN to build, then a vNext build needs to be able to use that same SLN in the same way. Instead vNext currently only offers MSBuild as the build tool. MSBuild has many more options than devenv, so that would be great, IF it could be made to use the SLN to govern dependencies in the same way as VS, and would be upgraded to build all the same project types.
There have been prospective efforts, referenced by PatrickLu-MSFT at Build project using devenv.exe in TFS 15RC1 Build Server, to enhance a vNext build step to allow devenv to be used instead of MSBuild, but those efforts seem to have been dropped.
Maybe someone has developed a custom vNext build step to build using devenv?
Here is an existing extension you can reference, which provides a build task in your TFS/VSTS instance that will allow you to build your projects using DevEnv.com (Visual Studio):
https://marketplace.visualstudio.com/items?itemName=mmajcica.devenv-build
If you want to automatically use TFS/DevOps build whatever solution files our development teams get working using Visual Studio, you could set CI trigger in build pipeline, when the solution build successfully on local, you can check in/commit the changes, and trigger TFS/DevOps builds.
I am trying to deploy an web application that was created on VB with the .NET Framework 2.0 using the TFS 2017 continuous deploy. It doesn’t have a solution file inside like vbproj or csproj, so I needed to avoid all the suggestions to include extra information on the vbproj.In order to run the MSBuild even locally I need to change in my .sln this tag, so all my compiled code is also there
Debug.AspNetCompiler.TargetPath = "....\PrecompiledWeb\ARB\Debug\"
Unfortunately, I can’t deploy the application using the TFS. So far I tried to deploy it through my Visual Studio project, and is working fine with every option: I tried MSDeploy, Web Deploy Package, and FileSystem, and is working fine from the Visual Studio Publish Option
With that, even my transformation take place.
Now lets say I go to my TFS and I put this parameters on the MSBuild
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsASingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="\\MyServer\Content"
My files are compiled but never stored in my Content folder. No one of them!!! I can’t figure out what is going on here.
From your screenshot, you are using a Web Site project, not a Web Application project. The output structure of a Web Site project in TFS is different from build in VS (you can see a PrecompiledWeb folder in your build source directory on build agent server). Instead of using MSBuild argument, you can consider add tasks below to copy the files you want to publish:
We strongly suggest you switch from Web Site projects to Web Application projects to avoid these issues.
Is there a way for a Web Deploy operation to Azure App Services to delete a specific folder on the server before the deployment starts?
I need certain files to be removed on the server when they are removed on the solution and deployment leaves those files intact on the server which is causing issues.
Is there any way to add this to the publishing profile as a pre-publish action?
Just to add more context, this is an ASP.NET project using C#. Sitecore is the CMS.
i have tried to find something specific to the SiteCore and not msbuild BeforePublish target, but it looks like you have two options here:
1) Use msbuild BeforePublish target
2) Use Visual Studio Team Services build Continuous Integration - it will need some additional manual tasks, but nothing serious and it is much more visual than msbuild.
I would highly recommend to try the second option - here, you can specify build steps like Take sources => build => execute some command (here is your place to put something for deleting the files) => publish.
I am currently using a build definition for continuous integration in TFS 2012.
I am using the following build arguments
/p:DeployOnBuild=true;PublishProfile=DEV_SERVER;Password=secret
and everything works well.
Now I need to publish the build to more than one site, and I have created the publishing profiles in visual studio. But how to tell MSBuild to use more than one profile?
/p:DeployOnBuild=true;PublishProfile=DEV_SERVER1;Password=secret /p:DeployOnBuild=true;PublishProfile=DEV_SERVER2;Password=secret /p:DeployOnBuild=true;PublishProfile=DEV_SERVER3;Password=secret
does not work. Only one site is published. (I'm not sure the first or last)
Does anyone know how to specify?
I know that I can duplicate the build definition on TFS using another profile in this new build definition, but in this case the application will be built TWO times and the releases on the servers have different build numbers.
you can specify publish xml in the MSBuild arguments
/t:Build /t:Publish /p:SqlPublishProfilePath=DEV.publish.xml
also this option only works for TFS2012 and VS2012