TeamCity Build Agent (v27767) deletes MsBuild.exe on run - visual-studio-2012

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?

Related

Appcenter iOS build fails when enabling sonarscanner

For an appcenter deployment I want to use SonarQube to analyze the code quality of the project. I have setup the appcenter-pre-build.sh and appcenter-post-build.sh scripts to install and enable Sonarscanner in the appcenter build process.
Now when I build for iOS, the build process fails, because it cannot find 2 files in the /Users/runner/work/1/.sonarqube folder on the build machine. Those files are /Users/runner/work/1/.sonarqube/conf/cs/SonarLint.xml and /Users/runner/work/1/.sonarqube/conf/4/ProjectOutFolderPath.txt.
I know for a fact that the /Users/runner/work/1/.sonarqube/conf/cs/SonarLint.xml is there, because in the logfile it says: "Writing Roslyn analyzer additional file to /Users/runner/work/1/.sonarqube/conf/cs/SonarLint.xml..." when running the appcenter-pre-build.sh script, which installs the sonarscanner.
I am installing the sonarscanner with the command: dotnet tool install --global dotnet-sonarscanner and the version that gets installed is 5.0.4.
On my SonarQube server I am running version 8.3 community edition and when the appcenter build runs, the analysis report appears in my project on my sonarqube server.
The build however fails.
Please advice on how to get the iOS builds in appcenter to succeed while sonarscanner is enabled.
Thank you in advance.
The problem is how appcenter logs the build process. From going through the logfiles, you get the impression that the build fails, because of the integration with Sonarqube.
The build failed however, because there were some context links missing in the c# code. Once this issue was found by building locally, The builds succeeded.

How do I execute my Visual Test project in the build output folder for Azure Devops Visual Studio Test task

On my local machine the Unit tests run successfully on the deployment folder. They fail when run on a local test deployment folder as some files are missing.
Is there a way to have the tests run on the deployment folder (as opposed to test deployment folder) when being run on Azure Devops Visual Studio Test task.
How do I execute my Visual Test project in the build output folder for
Azure Devops Visual Studio Test task
Since the issue you got came from missing assemblies. You should check how you configure the Test files and Search folder:
For yaml: check testAssemblyVer2 and searchFolder inputs.
According to your description, the VSTS test task is in classic release pipeline or multi-stage yaml pipeline.
If the build outputs you mean come from build task in build pipeline, consider using Download artifact task first to download the build outputs.
And If the build outputs come from build task in same pipeline, or from local machine. Just make sure the Search folder is set correctly to locate the assemblies.

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.

Auto-deployment with continuous integration of .NET CORE fails because it cannot modify the file 'xxx.exe'

I have created a new ASP.NET Core Web Application. I'm using TFS (2015 Update 2) MS Build process to build and deploy my application to my Dev/QA server. I'm running my code with a Kesrel/IIS configuration on a window server.
My build Steps are:
Command Line: dotnet Restore -- restores my nuget packages
Command Line: dotnet build -c Dev -- builds my dev profile
Command Line: dotnet publish --framework netcoreapp1.1 --runtime win7-x64 --output "C:_work\dev\svc" --configuration DEV --no-build
Publish Build Artifacts: from that output folder in step 3 to my web server.
Problem:
The major problem I have is that the new core applications all run as console applications, so there is an 'xxx.exe' file running, in addition to the w3svc.exe IIS app running. When my Publish Build Artifacts steps runs, the process fails because the 'xxx.exe' file is in use, and cannot be modified.
So far as I can tell, you have to use the "dotnet" CLI to build and publish your CORE applications, and you cannot use the VS Build steps.
I've tried pointing my "dotnet publish" command to directly to the web server, but that has the same problem. You can see in my "dotnet publish" command I'm indicating a configuration to use (DEV). However even if I have DEV setup in VS to do a webdeploy, the "dotnet publish" command ignores that and either puts the code in a default publish location, or the location I specified in the command. So that doesn't work like the old .net framework did either.
My hosting team won't give me access to run remote powershell scripts to stop the IIS apps and console application, and I don't see any other build steps that would work to build the CORE application.
I'm on TFS 2015 Update 2. We're soon going to be on Update 3, but I don't know if that will give me feature to fix this either. If anyone know, I'd love to hear it!!
If I stop IIS app pools and make sure the console app is also stopped, my Build and Deploy steps above, work perfectly, but I don't want to have to manually stop IIS app pools every time before a build.
ASP.NET Core still respects the presence of an app_offline.htm file, so if you can copy a file with that name to the app destination on your server before step 4, and remove the file after step 4, the deployment should work. The ASP.NET Core module watches for this file and shuts down the hosting process (the .exe).
I'm sure you can run msdeploy tasks from VSTS, and msdeploy has a parameter to create an app_offline.htm file for you (although there is currently a bug in the ASP.NET Core module deployed to Azure where the file has to be all lower case letters). Msdeploy does work in deploying a published Core application to IIS.
Since stopping IIS app pools can solve the issue, you may try to install IIS Utilities to stop or start Application pool.

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