Issue
I have a Xamarin Forms Android build pipeline on Azure DevOps, locally my applications build without a problem. When the pipeline runs, I get the following error when I attempt to do a NuGet Restore (the ios pipeline uses the same settings and restores without an issue).
Error
The imported project "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.CSharp.targets" was not found.
This is the line it fails at when trying to a NuGet Restore
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
I was not getting this issue yesterday and I have not made any .csproj
or .sln
changes, so I don't know why this issue has raised, appreciate the help.
Build agent
- windows-2022
- NuGet 5.9.1
Solution
As I commented, it seems like there was a change to the agents which now do not include the Xamarin Component in VS2022. You can read more about this in this GitHub issue: https://github.com/actions/runner-images/issues/6082
In that linked issue there is also a workaround, where you can install the Xamarin Component yourself. Note that this adds around 4 minutes extra to that pipeline just installing that component:
- pwsh: |
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
$componentsToAdd = @(
"Component.Xamarin"
)
[string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " + $_}
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
if ($process.ExitCode -eq 0)
{
Write-Host "components have been successfully added"
}
else
{
Write-Host "components were not installed"
exit 1
}
displayName: "Install Xamarin Components"
The alternative to this is to switch to macOS-12 agents and building on those instead.
Answered By - Cheesebaron
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.