Azure Devops pipeline is not picking latest visual studio version - azure

'Visual studio build solution task' in the Azure pipeline has latest visual studio version selected. However from the console log I can find it is not selecting the latest version (2022) instead it is selecting the 2017 version.
Even in the console log of my previous task (Nuget restore) I can see it is picking only the 2017 version.
Is there a way that I change the solution to Visual studio version 2019.
Note: Main reason I want to use 2019 version is because current version of my MSBuild is not compatible with VS version 2017. Because of this my pipeline is failing.
Is there a way I can change the VS version in Azure Devops pipeline. Can someone guide me please?

Is there a way I can change the VS version in Azure Devops pipeline?
You can use a MSBUILD task and switch from Version to Specify Location and insert the path to the msbuild.exe of VS2022.
Ex:
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\msbuild.exe.
Look at the screenshot below:
Note: Please make sure your path is correct in the MSBuild.exe task.

Since you are not providing a basic pipeline yml file (maybe you are using classic instead of yml?), we can only guess.
Is there a possibility that the NuGetCommand task is finding a solution file in your repo that references the 2017 version of VS?
NuGetCommand will "restore" (install) the version it finds unless something else overrides.

Related

Setup.exe build from azure pipelines prompts for .NET framework 4.7.2 on every run

We are trying to generate a click once application using azure devops pipelines.
During this, we publish the project to create a setup.exe. All the pre-requisites required are ticked, the project builds and publishes the setup.exe without any issues.
However, every time the setup.exe is run we see the prompt in Image 1.
Image 1
We have ensured the installURL is correct, and the .NET Framework 4.7.2 is on the build machine and install machine.
When we publish the project in visual studio, the setup.exe does not show this prompt.
Does anyone have any idea how to stop this prompt showing or what we could try next?
In your Visual Studio build task in your pipeline, make sure you have Visual Studio 2019 selected due to a bug in earlier versions of VS.
https://developercommunity.visualstudio.com/content/problem/743594/dotnetfx472-and-dotnetfx48-not-finding-information.html

Azure hosted agents - Visual Studio 2017

I set up a hosted agent in Azure to do a CI build but I'm getting the following warning during the Visual Studio build step before the build fails:
"Visual Studio version '15.0' not found. Looking for the latest version."
Looking at the documentation for hosted agents it looks like they're not deployed with Visual Studio 2017:
https://www.visualstudio.com/en-gb/docs/build/concepts/agents/hosted
Does anyone know when the hosted agents will be deployed with Visual Studio 2017 or when this will be likely?
When selecting your agent queue, you can now select the "Hosted VS2017".
You may need to adapt your build pipeline. For instance I had to remove the Nuget Restore step I had and just ticked the "restore nuget package" in the build step. The standard Restore Nuget step was trying to use MsBuild 14 which is not available on VS2017 agents.

Azure Webjobs publish error (active directory)

When I try to publish an azure webjob, I get the following error:
An error occurred while creating the WebJob schedule: Could not load type 'Microsoft.IdentityModel.Clients.ActiveDirectory.ActiveDirectoryAuthenticationException' from assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.16.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
The same question is asked in Visual Studio 2015 Publish WebJobs Issue, but the accepted answer does not solve my case.
I tried to add the nuget package for ActiveDirectory version 2.16, but that didn't solve it either.
There is now a better way of scheduling WebJobs using CRON expressions, which is simpler and avoids all the Scheduler issues.
I have added a new answer to the existing question, to keep everything in context of the original answers.
See details on Visual Studio 2015 Publish WebJobs Issue
I found the solution as i have been stuck in this error for a while.
The issue turns to be that it is a bug in Visual Studio 2015 Update 3. It uses old webjobs publishing tools even if you have newer NuGet packages.
After looking at the source of the problem in the output window, Visual Studio build tools were looking for an older webjobs publishing package ver. 1.0.3 while i have 1.0.12 on my pc.
Below screen shot shows that my csproj file contains 5 publishing packages.Everytime i deploy it checks for the first condition and uses 1.0.3 while i want the build tools to use 1.0.12!
The fix for this is to unload the project in Visual Studio 2015, Edit the .csproj file and delete the older NuGet publish packages from the build targets.
Rebuild, Publish, The webjob will be deployed to Azure and a scheduler will be created with no issues!
Hope this helps.

Invoke a publish from msbuild for visual studio 2012

For VS2010 and before I was utilizing Web Deployment Projects (WDP) to help package my website for production deployment. I had a MSBuild script that compiled the solution in release mode. An output of that was production ready website files compiled and cleaned by the WDP.
I see for 2012 WDP have been removed, and a new tab has been created in the properties for the web application. The options are the same, but now the invocation of this is done via the Publish option (before you just compiled in release mode).
So the question is this. From an MSBuild script, how do I invoke a Publish operation? I found some old posts that...
msbuild /target:publish
would do the trick. But that doesn't seem to work in 2012.
Also, I tried in my msbuild task...
<MSBuild Properties="Configuration=Publish;"
StopOnFirstFailure="true"
Projects="$(BuildDirectory)\MySolution.sln"></MSBuild>
...but msbuild just reported "unknown configuration".
How can I have msbuild run the publish option from the command line?
It appears that there are now some other options for publishing from the command-line. Specifically something along the lines of the following seems possible now with some RC updates to Visual Studio 2012.
msbuild mywap.csproj /p:DeployOnBuild=true;PublishProfile=MyProfileName
For more details check out this post by Scott Hanselman and check out the section on Publishing.
I wasn't able to get the publish to run, but looking at the output from Visual Studio I think I have found an alternate solution. Turns out the obj\Release\AspnetCompileMerge folder has a deployable and clean version of the project. It contains byte identical files to the final output folder.
I did have to change my msbuild script to include the DeployOnBuild option...
<MSBuild Properties="Configuration=Release;DeployOnBuild=True;"
StopOnFirstFailure="true"
Projects="$(BuildDirectory)\BigWave.ALL.sln"></MSBuild>

How to use MSBuild to target v110 platform toolset?

I am developing a command line application that creates a full Visual Studio 11 solution made of a single VC++ project and that tries to compile it in the end using MSBuild.
The problem I am facing is strange.
If I execute my command line program inside Visual Studio 11 it works; if I instead launch it outside the development environment it throws me the error:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(511,5): error MSB8008: Specified platform toolset (v110) is not installed or invalid. Please make sure that a supported PlatformToolset value is selected. [f:\ABC.vcxproj]
The command I am using is the following:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe f:\snake\W9A30040.vcxproj /property:PlatformToolset=v110;Configuration=Debug /v:quiet
But I have the feeling that PlatformToolset=v110 is ignored and MSBuild use v100 (Visual Studio 2010).
Do you have any suggestions how to tell MSBuild to compile for v110 Platform Toolset?
I ran into the same problem as well with the full release of VS 2012. You can also set the VisualStudioVersion as a property with MSBuild as opposed to dealing with environment variables as mentioned in the accepted answer. For instance:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\myproject.vcxproj /p:VisualStudioVersion=11.0
The environment variables approach I'm sure work just as well, I honestly didn't try that as I was trying to stay away from having to modify the environment variables.
Make sure that the top of your .SLN file looks like this:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
When you double-click on the solution file, it's the # Visual Studio 2012 that controls which version of Visual Studio is loaded (and controls the icon displayed in Windows Explorer).
However, when you run MSBuild, it looks at the Format Version 12.00 part.
Confused?
This is confusing, since Visual Studio 2010 is version 10.0 and Visual Studio 2012 is version 11.0 (not 12.0), and using the version 12.0 solution file format causes MSBuild to (implicitly) set VisualStudioVersion to 11.0.
I found a workaround for this issue; could be a problem of Visual Studio 11 Beta that will be resolved before official release.
Anyway, if you are interestedm just set the environment variable "VisualStudioVersion" equal to "11.0" before calling MSBuild.exe.
In batch files
set VisualStudioVersion=11.0
or in VB.NET
Environment.SetEnvironmentVariable("VisualStudioVersion", "11.0")
Starting with Visual Studio 2013, MSBuild is now part of Visual Studio, and the correct path should be $(MSBuildToolsPath) (“C:\Program Files (x86)\MSBuild\12.0\Bin”). If you use msbuild.exe from the .Net framework folder (“C:\Windows\Microsoft.NET\Framework64\v4.0.30319”) it will not able to distinguish the vs2012 and vs2013 versions.
Use the menu based options to do this. From VC++2010 Express:
- Right click on the main file of the project (not the solution itself at the very top of the tree).
- Click General.
- Find Platform Toolset on the right side of the dialog, top half.
- Change from v110 to v100.
- Click OK.
----- Done ------
Microsoft provides a batch file to set all the EnvVars
You find it in the Start Menu under "Microsoft Visual Studio 2012/Visual Studio Tools" or in the Visual Studio folder ("C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat")

Resources