Visual Studio Team Services build server in Azure - azure

I am trying to create a custom build server for Visual Studio Team Services in Azure. I have installed the build agent and Visual Studio Express on a virtual machine which is running and connected to my project on visualstudio.com as a build agent in the "Default" pool.
However when I tried to run a build I got the following error:
No agent found in pool 1 which satisfies the specified demands:
msbuild
visualstudio
vstest
Agent.Version -gtVersion 1.98.1
MSBuild was already in the list of capabilities on visualstudio.com but not the other two, so I dug through C:\Program Files (x86) and added these two capabilities to the list:
vstest: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow
visualstudio: C:\Program Files (x86)\Microsoft Visual Studio 14.0
The build then runs at least but I get another error during the "Test Assemblies" step. I think the most important part of the error message is Unable to determine the location of vstest.console.exe, here it is in full anyway:
System.Management.Automation.CmdletInvocationException: Unable to determine the location of vstest.console.exe ---> System.IO.FileNotFoundException: Unable to determine the location of vstest.console.exe
at Microsoft.TeamFoundation.DistributedTask.Task.Internal.PowerShell.InvokeVSTestCmdlet.GetVsTestLocation()
at Microsoft.TeamFoundation.DistributedTask.Task.Internal.PowerShell.InvokeVSTestCmdlet.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at Microsoft.TeamFoundation.DistributedTask.Handlers.PowerShellHandler.Execute(ITaskContext context, CancellationToken cancellationToken, Int32 timeoutInMinutes)
at Microsoft.TeamFoundation.DistributedTask.Worker.JobRunner.RunTask(ITaskContext context, TaskWrapper task, CancellationTokenSource tokenSource)
I have looked and vstest.console.exe is located in the vstest folder I specified above, I've also tried adding this folder to the system PATH but that makes no difference.
How can I set up a working build agent in Azure?

Visual Studio Express doesn't have the testing tools. Install Visual Studio Community (assuming you qualify for Community based on the licensing terms), or a Visual Studio edition (professional/enterprise) for which you or your organization is licensed.

In TFS Build Logs under Test Assemblies I see the error:
System.Management.Automation.CmdletInvocationException: Unable to determine the location of vstest.console.exe
I had VSTest set as Visual Studio 2015, I'm using VS/TFS2017 so switching to Latest solved the problem:

You'll want to install Visual Studio on your build server. At that point, the build agent will recognize the capabilities available like msbuild, visualstudio, and vstest.

I found a solution, you just have to convince your build machine that it does actually have VS installed. From the link:
What worked for me was to create the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0
and within that key, create a new value of type string with name
ShellFolder and value C:\Program Files (x86)\Microsoft Visual Studio
14.0.
Hope it helps

Related

Installed Custom Visualizer not loading in VS2022

I am trying for some hours to install a custom visualizer in VS2022. Basically it is a simple string visualizer that opens a wpf form.
I followed this: https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-install-a-visualizer?view=vs-2022
But the instructions do not seem to work.
When the visualizer and the test console app are in the same solution, the visualizer works, shows up. Everything is alright, but that is not of too much help
What I have tried until now, but without success:
Copy all visualizer dlls in C:\Users\XXXX\Documents\Visual Studio 2022\Visualizers
Copy all visualizer dlls in C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\Packages\Debugger\Visualizers
Checked on multiple projects, some targeting .NET Framework 4.7.2, some .NET 6
Checked on one of my colleagues pc, also with VS2022
Copied all dlls to a folder here(where I found DataSetVisualizer and IEnumerableVisualizer): C:\Program Files\Microsoft Visual
Studio\2022\Professional\Common7\IDE\CommonExtensions\Platform\Debugger\
Run devenv /ResetSettings from an admin console
Run devenv /resetskippkgs from an admin console
Run Visual Studio as administrator
Checked in Debug => Windows => Modules to see if the custom dll is loaded
Do you guys have any idea what should I try? Or what could be the problem?
Did any of you succeeded in running a custom visualizer in VS2022
Thank you
So, after some days, and many hours of trial and error, I could finally install and see my custom visualizer.
Basically, what I have done and (I think) it solved the issues:
Cleaned up all the dlls from "C:\Users\XXXX\Documents\Visual Studio 2022\Visualizers" and all of its subfolders corresponding to .net framework versions
Checked that my visualizer corresponds to the correct type:
[assembly: DebuggerVisualizer(
typeof(DebuggerSide),
typeof(TextChunkObjectSource),
Target = typeof(IEnumerable),
Description = "PDF Visualizer")]
Don't put List<TextChunk>, or IReadOnlyList<TextChunk>, instead of IEnumerable<TextChunk>
Delete bin folder(s) and rebuild the visualizer project
Make sure to copy the dlls in all the needed folders:
I had to copy them here:
C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\Packages\Debugger\Visualizers\
C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\Packages\Debugger\Visualizers\netstandard2.0\
C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\Packages\Debugger\Visualizers\netcoreapp\

Platform Toolset = 'v150' cannot be found

The problem described below was resolved by changing the Pipeline yaml. The Build.proj that was included had incorrect parameters. It was pilot error.
I have a VisualStudio 2017 solution which builds in VS, when I push the Branch to merge with a Microsoft Hosted Azure DevOps Git master, the pipeline fails saying Platform Toolset = v150 cannot be found. I cannot find Platform Toolset v150 anywhere.
The Platform Toolset used when it successfully builds on VS2017 is v141, and is v142 on VS2019. It builds as Release x64 on both VS2017 and 2019. Since v150 does not exist, I assume that this is some sort of unexplained error condition.
I don't know where to look for better clues about what failed.
Here is the error:
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(67,5): Error MSB8020: The build tools for v150 (Platform Toolset = 'v150') cannot be found. To build using the v150 build tools, please install v150 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [D:\a\1\s\xxxxxxxxxxxxxxx.vcxproj]
I have also run the build from the command line as:
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" build.proj /t:Build /verbosity:normal /fileLogger /fileloggerparameters:Append
and see the same "v150 cannot be found" error

Azure pipelines: error MSB4019 WebApplication.targets was not found

I created an episerver alloy project, which builds and runs fine in visual studio after setting up some nuget packages, and I can deploy to azure and run in azure from VS without issue.
I am now trying to get the build to work in pipelines.
Following the instructions, I added a "nuget restore" task, and pointed it at a NuGet.config.
This works.
Then it gets to the build stage, and gives:
D:\a\1\s\DxcAlloy.csproj(335,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\3.1.202\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.202\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.
I have no idea how to debug this. Some posts say that error can happen if you dont have visual studio installed, but I cant install visual studio on azure pipelines...
I removed the existing ".net restore" task, as it failed, and am guessing that just my nuget restore is all I need - this is a guess.
The pipeline "agent specification" is vs2017-win16
The project was created in VS 2019.
In desperation, I added a "Use .NET core" task, and set the version to the one which build is complaining is missing, i.e. 3.1.202.
This didn't help.
Any ideas?
If you build your project using dotnet build task. Below configuration in your .csproj file will be evaluated to C:\Program Files\dotnet\sdk\3.1.202\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets (What you see from the error)
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v16.0</VSToolsPath>
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" />
Microsoft.WebApplication.targets usually exists in below location. That is why it errors out ...Microsoft.WebApplication.targets not found.
In Visual Studio 2017 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets"
In Visual Studio 2019 "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets"
The workaround for above issue is using Msbuid task or Visual Studio build task to build your projects. See below example:
- task: VSBuild#1
inputs:
solution: '**/*.csproj'
enabled: true
For your case, you also need to set agent specification to agent windows-latest. For visual studio 2019(v16.0) is only installed in agent windows-latest.
If you have to run your pipeline on agent "vs2017-win16" (only visual studio 2017(v15.0) is installed). You need to change the VSToolsPath in the .csproj file to <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v15.0</VSToolsPath>
If you have to use dotnet build to build your projects. You can hard code the import path in csproj file as workaround.
<Import Project="C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" />

Behaviour MSBuild in VisualStudio 2015 differs from MSBuild in Console

Affects: Visual C++ in Visual Studio 2015
When I start a build on my project in the VS-Solution it compiles all the project's source files. If I do it again and I have nothing changed, the build is up to date. But if I build from console like:
msbuild c:\path\to\my\project\my-project.vcxproj /t:build /p:configuration=Debug /p:Platform=Win32 /p:VisualStudioVersion=14.0.25425.01
... the sources will be compiled again. (By building again in console, the build is up to date, too. On building after a console-build in VS, the build compiles all the project's source files.)
I noticed that my VS-Version (14.0.25425.01) differs from the showing console output (14.0.25420.1), so I added the /p:VisualStudioVersion=14.0.25425.01-Parameter.
But this did nothing (even the console's output is still to Microsoft (R)-Buildmodul, Version 14.0.25420.1).
Maybe this can be the problem? But if, How do i fix it?
I also noticed via the Windows TaskManager, that the MSBuild.exe-Runtime started by Visual Studio will be active until VS is exited. (In my console, the MSBuild.exe-runtime ends, when the build has finished.)
Another curious thing i've noticed is, that in my console sometimes MSBuild.exe is started from C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE (as always from Visual Studio) and sometimes MSBuild.exe is started from C:\Program Files (x86)\MSBuild\14.0\Bin. By comparing those files, they're identical.

MSBuild Tools 2017 with Azure SDK 2.9.6

Yep there are similar question out there, but they are not related to VS 2017:
Visual Studio Build - Azure 2.9 SDK
MSBuild MSB4096 error with Azure SDK 2.9.1
I've recently upgraded from VS 2015 to VS 2017. On my local dev computer everything works fine and the Azure application (with Azure SDK 2.9.6) builds and starts.
But on the TeamCity server (MS Build Tools 2017 - Tool version 15.0) I get the following error:
MSB4019: The imported project "C:\Program Files (x86)\Microsoft
Visual
Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\Windows
Azure Tools\2.9\Microsoft.WindowsAzure.targets" was not found. Confirm
that the path in the declaration is correct, and that the
file exists on disk.
The build server/MSBuild tries to find the Microsoft.WindowsAzure.targets in the directory:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\Windows Azure Tools\2.9\
But it is actually in the directory:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\[VisualStudioVersion]\MSBuild\Microsoft\VisualStudio\v15.0\Windows Azure Tools\2.9\
[VisualStudioVersion] can have the following values "Community", "Professional" ,"Enterprise"
Yes, I've the build tools installed (https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15 ).
Yes, I already copied the whole Windows Azure Tools folder to BuildTools\MSBuild\Microsoft\VisualStudio\v15.0, but then I get another error in my F# project:
MSB4057: The target "GetTargetFrameworkProperties" does not exist in
the project.
It seems like the new MS Build Tools 2017 doesn't work properly with Windows Azure. Are there any workarounds yet? Or is the only option to switch back to an older MSBuild?
The new standalone BuildTools currently don't support Windows Azure targets.
So if you want to use the new MSBuild 2017 with Azure SDK you have to install a full VS 2017 installation on your build server.
Note: You may have to restart the TeamCity (agents) in order to recognize the MSBuild path. After running a build you can see the used MSBuild paths in the tab 'parameters':
MSBuildTools15.0_x64_Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\[VS_VERSION]\MSBuild\15.0\bin\amd64
MSBuildTools15.0_x86_Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\[VS_VERSION]\MSBuild\15.0\bin
[VS_VERSION] can be Community, Professional or Enterprise
I still got the GetTargetFrameworkProperties error from the F# project, this was resolved by adding the flag:
/p:VisualStudioVersion=15.0
to the MSBuild task.
For more information see https://github.com/Microsoft/msbuild/issues/1888

Resources