Skip to content

Conversation

mjbond-msft
Copy link
Contributor

@mjbond-msft mjbond-msft commented Jun 18, 2020

There have been a few issues involving Android builds on Windows involving problems with the VS installation or an incorrect (older) version of MSBuild being invoked. This build step provides visibility into the VS and MSBuild installations installed on the windows build agent. It utilizes vswhere as a means to enumerate and obtain the VS installations on the agent. Additionally, the template being called leverages code from the MSBuild task to locate the version of MSBuild that will be used.

@mjbond-msft mjbond-msft requested a review from pjcollins June 18, 2020 15:49
@mjbond-msft mjbond-msft requested a review from jonpryor as a code owner June 18, 2020 15:49
@mjbond-msft mjbond-msft self-assigned this Jun 18, 2020
@jonpryor
Copy link
Contributor

jonpryor commented Jun 18, 2020

@jonpryor
Copy link
Contributor

Commit Message-

Summary:

[ci] Show VS & MSBuild install locations on Windows (#4833)

Body:

Context: https://github.com/xamarin/yaml-templates/blob/cf440bcf4daf0305be17280bf27854480314db77/environment/win/vs-msbuild.v1.yml

Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3795214&view=logs&j=cac0e8d3-0ef5-5d2b-b57e-e8fde7204df3&t=b0ec5c6c-f5a1-5ebf-2068-57a5c78a6a85

There have been a few issues involving Xamarin.Android builds on
Windows involving problems with the Visual Studio installation or an
incorrect (older) version of MSBuild being invoked:

	##[debug]Entering Invoke-VstsTool.
	##[debug] FileName: 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe'
	##[debug] Arguments: '"C:\A\vs2019xam000013-1\_work\2\s\Xamarin.Android.sln" … /t:Prepare /p:AutoProvision=true /bl:C:\A\vs2019xam000013-1\_work\2\s\bin\BuildRelease\msbuild-prepare.binlog …
	##[debug] RequireExitCodeZero: 'True'
	"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" …
	MSBUILD : error MSB1001: Unknown switch.
	Switch: /bl:C:\A\vs2019xam000013-1\_work\2\s\bin\BuildRelease\msbuild-prepare.binlog

	For switch syntax, type "MSBuild /help"
	##[debug]Exit code: 1

We're not entirely sure why this happens.

Add a template include to `environment/win/vs-msbuild.v1.yml@yaml`,
which adds two new steps to **Windows** > **Build and Smoke Test**:

  * `Env: Create Write-MSBuildPath.ps1`, which creates a
    PowerShell script

  * `Env: Visual Studio (Windows)`, which invokes the
    `Write-MSBuildPath.ps1` script, printing out information about
    the currently installed Visual Studio instances.

The new steps provide visibility into the Visual Studio and MSBuild
installations, utilizing `vswhere` as a means to enumerate and obtain
the Visual Studio installs on the agent.  Additionally, the template
being called leverages code from the MSBuild task to locate the version
of MSBuild that will be used:

	Visual Studio installations based on the vswhere.exe command
	…
	[
	  {
	    …
	    "installationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise",
	…

	Visual Studio installed products:
	  Microsoft.VisualStudio.Product.Enterprise 16.6.30114.105: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
	      IsComplete: True
	      IsLaunchable: True
	      IsRebootRequired: False
	    MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe

@pjcollins
Copy link
Member

@mjbond-msft I think we should also add this to our other windows Job that runs on this Windows pool, I'd suggest here:
https://github.com/xamarin/xamarin-android/blob/master/build-tools/automation/yaml-templates/run-msbuild-win-tests.yaml#L19

@jonpryor jonpryor merged commit 28dbfe4 into master Jun 19, 2020
@jonpryor jonpryor deleted the dev/bond/agent-env-win branch June 19, 2020 19:02
@github-actions github-actions bot locked and limited conversation to collaborators Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants