Jenkins msbuild deploy to remote IIS - iis

I have a Jenkins build server and a remote IIS server.
I would like my Jenkins server to build and deploy to the IIS using MSBuild and publish profile I created.
The publish profile is created from Visual Studio and it's working fine when publishing from VisualStudio.
I'm running the following command from the Jenkins Server:
msbuild myproject.csproj /p:DeployOnBuild=True /p:PublishProfile=CustomProfile /p:VisualStudioVersion=14.0 /p:AllowUntrustedCertificate=True
The build is success but the files are not published to the IIS and there is no error reported.
Can anyone help me understand what is the right MSBuild command that will also publish the new version to the IIS server.
Thanks

As stated on Microsoft's website:
To deploy to Azure, you must add the password to the command line. If you saved the password in the publish profile in Visual Studio, it was stored in encrypted form in the your .pubxml.user file. That file is not accessed by MSBuild when you do a command line deployment, so you have to pass in the password in a command line parameter.
Your command should include the password parameter:
msbuild myproject.csproj
/p:DeployOnBuild=true
/p:PublishProfile=CustomProfile
/p:Password=hdNSWsbuqno7J5uqnwKafwlfNPt1DSco7J5uqnwKafwlfNPt1DSpKHuYgCco7J5
/p:AllowUntrustedCertificate=true
Your password is found in .publishsettings
References
https://learn.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/command-line-deployment

Related

msbuild.exe does not run on Linux VM in Azure

I am trying to use Jenkins to run my unittests. I have made a Jenkins Project for a build with a buildstep "Build a Visual Studio Project using MSBuild". My Jenkins server is installed on a linux vm which is in Azure.
You can see it here in the Jenkins UI:
When I run the build I get this Console Output:
Path To MSBuild.exe: msbuild.exe
FATAL: Unable to use this plugin on this kind of operation system
Executing the command msbuild.exe /ContinuousIntegration/ContinuousIntegration.sln from
/var/lib/jenkins/workspace/CSHARP_CI_TEST - UNITTEST
[CSHARP_CI_TEST - UNITTEST] $ msbuild.exe
/ContinuousIntegration/ContinuousIntegration.sln
Build step 'Build a Visual Studio project or solution using MSBuild' changed
build result to FAILURE
Build step 'Build a Visual Studio project or solution using MSBuild' marked
build as failure
Finished: FAILURE
I think the problem here is that I am trying to use msbuild.exe on a Linux VM. Is there a workaround for this or is it not possible to do this?
I have tried to use the msbuild.exe on the vm via a linux terminal, but it is not possible to run it.
To accomplish your requirement you have to install '.NET Core SDK' in the Azure Jenkins Linux VM and then you may simply use 'Execute shell' build step with the command 'dotnet build ContinuousIntegration/ContinuousIntegration.sln'
To install '.NET Core SDK' in your Azure Jenkins Linux VM, please go to https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install and click on 'Linux' in that page and then select the required Linux distribution and follow the steps provided.
For more information on MSBuild support on various operating systems, please refer https://github.com/Microsoft/msbuild/blob/master/documentation/wiki/Building-Testing-and-Debugging-on-.Net-Core-MSBuild.md
Just FYI, I have tested and reproduced your scenario and faced the same error which you have mentioned and then I have followed the above process and resolved the issue successfully. So I hope this helps. Cheers!!
PS: in your shell script you have to cd to the right folder for this to work.

TeamCity Build Agent (v27767) deletes MsBuild.exe on run

TeamCity 8.0.6 CI box with build agent has been purring along for several years. After a system restart, TeamCity seems to have auto-upgraded the local build agent to version 27767. No other configuration changes were made, but this error now shows on build trigger:
Unable to find MSBuild at C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe, please check MSBuild environment variable to target to Microsoft .NET Framework 2.0/3.5/4.0 or Mono installation directory
I RDP'd into the box and see that MSBuild.exe went missing - strange. So I re-add it from a local install and retrigger a build. As soon as the build agent picks up the file, it disappears! Happens every time. Maybe Windows is protecting this folder?
The build agent then becomes "incompatible". I tried this workaround, but this doesn't stop msbuild.exe from being deleted.
I checked that there are no odd steps in my build configuration. What could be deleting or moving MSBuild?

MSBuild not triggering WebDeploy on Wndows Server 2012 R2

In my development machine I can successfully deploy from Visual Studio 2015 to IIS 8.5 installed on Windows Server 2012 on my local network.
msbuild projectname.csproj
/p:VisualStudioVersion=14.0
/p:DeployOnBuild=true
/p:DeployTarget=MSDeployPublish
/p:MsDeployServiceUrl=https://myserver:8172/msdeploy.axd
/p:AllowUntrustedCertificate=True
/p:DeployIisAppPath=projectname
/p:Username=tc
/p:Password=pass
On my Windows Server I have installed msbuild, webdeploy and webdeploy for hosting services.
However, running the same command results in:
0 errors
1 warning (...Conflicts between different versions of the same dependent assembly...)
Build succeeded
And it doesn’t continue to deploy, no errors , no messages.
Do I have to resolve the warning message for msbuild to deploy or am I missing something else?
Thank you Microsoft for such a great verbose mode of this tool that says absolutely nothing when I tell it to deploy!!!
The solutions is here:MSBuild not triggering WebDeploy
It requires both folders to be present on the server:
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications
C:\ProgramFiles (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web
I was missing the second one (facepalm).

Publish to Azure fails with " Unrecognized link extension 'contentLibExtension'" Error

I am trying to publish ASP.NET MVC 6 App to Azure with Visual Studio 2015 CTP. And getting the following error
Publishing with publish method [MSDeploy]
Calling msdeploy with the command: ["C:\Program Files (x86)\IIS\Microsoft Web Deploy\msdeploy.exe" -source:IisApp='C:\Users\*****\AppData\Local\Temp\AspNetPublish\NgCalendar-28\wwwroot' -dest:IisApp='ngcalendar',ComputerName='https://ngcalendar.scm.azurewebsites.net/msdeploy.axd',UserName='$ngcalendar',Password='{PASSWORD-REMOVED-FROM-LOG}',IncludeAcls='False',AuthType='Basic' -verb:sync -enableLink:contentLibExtension -enableRule:DoNotDeleteRule -retryAttempts:2 ]
INVOKEPOWERSHELL(0,0): Error : Unrecognized link extension 'contentLibExtension'.
INVOKEPOWERSHELL(0,0): Error count: 1.
Not sure where it's coming from and how to tweak it.
Try deselecting "Publish using PowerShell script" checkbox in publish Settings
It worked for me
I had the same error.
In my case the problem was an old version of "msdeploy.exe".
After some searching I found one "msdeploy.exe" in the folder "C:\Program Files (x86)\IIS\Microsoft Web Deploy\msdeploy.exe" which caused the problem and another one in the folder "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe".
As I don't know how to change the path in Visual Studio to the newer version, I just saved the old folder and copied the complete content of the new folder into the old.
After this everything worked for me and I was able to publish to Azure :)
Hope this helps.

How to determine if MSBUILD Arguments were executed for TFS Build Definition

I am using Team Foundation Service 2012, with a build controller hosted internally so I can deploy apps to our web servers. I setup the Build Definition, and am using the my Debug configuration, and have supplied the following MSBUILD arguments.
/p:DeployOnBuild=true /p:DeployTarget=MSDeployPublish /p:MSDeployPublishMethod=WMSVC /p:MSDeployServiceUrl=https://myserversname:8172/msdeploy.axd /p:AllowUntrustedCertificate=true /p:DeployIisAppPath="somesite.ourdomain.com" /p:Username=na\svc-users /p:Password=PASS /p:VisualStudioVersion=11.0
The solution builds just fine, I get no warnings, or errors. When I go my deployment server, the application is empty. I have setup the permissions to the web application folder, and inetsrv folder. I also installed/configured web deploy. If I am not getting any errors returned how can I tell what is going wrong with my Deployment? I have already checked the Event Logs on both the Build server, and the Deployment server, and neither have any errors or warnings. I can also do a publish from my dev machine and it works perfectly with the exact same parameters.
Copy these two folders, and their content, from your development environment to the build server:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications
These folders are a dependency which is caused by publishing through Visual Studio 2012. This dependency is referenced in the .sln file.
Unfortunately this means web deploy is failing silently.
Alternatively you could install Visual Studio on the build server but that would be a waste of a license.

Resources