runner-images
runner-images copied to clipboard
Source generators have been disabled on the current configuration, as they need Roslyn 4.x
Description
When Building a Xamarin project on
- `vmImage: 'macos-latest'
-
task: XamariniOS@2
using CommunityToolkit.Mvvm.targets the build fails with
Users/runner/.nuget/packages/communitytoolkit.mvvm/8.0.0-preview3/buildTransitive/netstandard2.1/CommunityToolkit.Mvvm.targets(41,5): warning : The MVVM Toolkit source generators have been disabled on the current configuration, as they need Roslyn 4.x in order to work. The MVVM Toolkit will work just fine, but features relying on the source generators will not be available.
Platforms affected
- [X] Azure DevOps
- [ ] GitHub Actions
Virtual environments affected
- [ ] Ubuntu 18.04
- [ ] Ubuntu 20.04
- [ ] Ubuntu 22.04
- [ ] macOS 10.15
- [X] macOS 11
- [ ] macOS 12
- [ ] Windows Server 2019
- [ ] Windows Server 2022
Image version and build link
`vmImage: 'macos-latest'
Is it regression?
no
Expected behavior
Project to successfully build with source generators
Actual behavior
Build fails
Repro steps
- Using [ICommand] or [ObservableProperty] source generators project fails to build due to missing roslyn 4.0
@roughiain Hi!
Could you provide a minimalistic repo with a sample to reproduce the issue?
Will do one and attach @mikhailkoliada
@mikhailkoliada https://github.com/roughiain/PipelineTestSourceGenerators
pipeline output in https://github.com/roughiain/PipelineTestSourceGenerators/blob/b1bafb10c491c1bb6f54900009e20ff1415f2f0d/pipelineoutput.txt
Same issue with 8.0.0-preview4 can't buid or run in VS MAC
@mikhailkoliada Any update
Hey @roughiain, we have not had a chance to take a look yet :(
Hi, @roughiain and @Midnayt 👋 The root cause of the problem is in the version of the Roslyn compiler that is bundled into the Mono project. By now the latest stable version of the Mono is 6.12.0.182 and Roslyn 3.9.0-5.21112.8 is bundled into it. I created this request to update Roslyn's version in the Mono's repo. As a workaround, instead of using XamariniOS@2, you can try to build your application by hand using dotnet build
command with the same flags which you specified in XamariniOS task:
- bash: dotnet build /p:Configuration=Release /p:Platform=iPhone /t:Clean "./TestPipeline/TestPipeline.iOS/TestPipeline.iOS.csproj"
Don't forget to change the path to Xamarin iOS targets by changing these lines in TestPipeline.iOS.csproj to:
</ItemGroup>
<Import Project="/Library/Frameworks/Xamarin.iOS.framework/Versions/15.4.0.0/lib/msbuild/iOS/Xamarin.iOS.CSharp.targets" />
<ItemGroup>
This appears to still be a problem 28 days later Is there an easier way to resolve this? I don't want a custom script .. Appcenter is old enough it should work just fine by now I need this to work for Android and iOS
Hi, @stephenhauck 👋 Unfortunately, we are still waiting for an answer from the mono
team.
Seem like when your commercial product relies on it you should do more than wait ?
just piping in here - running into the same issue trying to get CI working for Xamarin iOS / Android using github actions
Sample failing github actions here https://github.com/InquisitorJax/Xamarin-Forms-Github-Actions/actions
perhaps there's a way to tell github actions to use a version of msbuild which includes the Roslyn 4.x compilers?
Hi, @roughiain and @Midnayt 👋 The root cause of the problem is in the version of the Roslyn compiler that is bundled into the Mono project. By now the latest stable version of the Mono is 6.12.0.182 and Roslyn 3.9.0-5.21112.8 is bundled into it. I created this request to update Roslyn's version in the Mono's repo. As a workaround, instead of using XamariniOS@2, you can try to build your application by hand using
dotnet build
command with the same flags which you specified in XamariniOS task:- bash: dotnet build /p:Configuration=Release /p:Platform=iPhone /t:Clean "./TestPipeline/TestPipeline.iOS/TestPipeline.iOS.csproj"
Don't forget to change the path to Xamarin iOS targets by changing these lines in TestPipeline.iOS.csproj to:
</ItemGroup> <Import Project="/Library/Frameworks/Xamarin.iOS.framework/Versions/15.4.0.0/lib/msbuild/iOS/Xamarin.iOS.CSharp.targets" /> <ItemGroup>
Hi Ivan. I have tried this workaround, but I get the following error
/usr/local/share/dotnet/sdk/6.0.400/Microsoft.Common.CurrentVersion.targets(1220,5): error MSB3644: The reference assemblies for Xamarin.iOS,Version=v1.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/Users/ivandjikovski/Projects/SourceGeneratorsRepro/TestApp.iOS/TestApp.iOS.csproj]
Here is a link to a repro project. I changed the import project as suggested and the build command is this one:
dotnet build TestApp.iOS.csproj -t:restore -t:rebuild -p:Configuration=Release -p:Platform=iPhone
Why are we being presented with workarounds when Roslyn 4 has been out for so long ? If I can build on my desktop with Visual Studio then CI / CD of Appcenter, Git Hub actions or Azure build pipelines should ALL work out of the box ...
Hi, @InquisitorJax and @idzikovski 👋 To use the MSBuild which has Roslyn 4.x
, you need to use dotnet build
command instead of msbuild
, because msbuild
points to MSBuild incorporated into the Mono, which currently still doesn't have Roslyn 4.x
. When you specify dotnet build
, it points to the MSBuild incorporated into SDK which has Roslyn 4.x
. As for question from @idzikovski, try to use this command: dotnet build TestApp.iOS.csproj -t:clean -p:Configuration=Release -p:Platform=iPhone
.
Why are we being presented with workarounds when Roslyn 4 has been out for so long ? If I can build on my desktop with Visual Studio then CI / CD of Appcenter, Git Hub actions or Azure build pipelines should ALL work out of the box ...
Hi, @InquisitorJax and @idzikovski 👋 To use the MSBuild which has
Roslyn 4.x
, you need to usedotnet build
command instead ofmsbuild
, becausemsbuild
points to MSBuild incorporated into the Mono, which currently still doesn't haveRoslyn 4.x
. When you specifydotnet build
, it points to the MSBuild incorporated into SDK which hasRoslyn 4.x
. As for question from @idzikovski, try to use this command:dotnet build TestApp.iOS.csproj -t:clean -p:Configuration=Release -p:Platform=iPhone
.
Thanks for the reply, this builds successfully, but it doesn't generate a binary. It seems as dotnet build ignores the properties in the csproj file such as <BuildIpa>true</BuildIpa>
. Is there a way to configure dotnet to create the ipa file?
Hi, @InquisitorJax and @idzikovski 👋 To use the MSBuild which has
Roslyn 4.x
, you need to usedotnet build
command instead ofmsbuild
, becausemsbuild
points to MSBuild incorporated into the Mono, which currently still doesn't haveRoslyn 4.x
. When you specifydotnet build
, it points to the MSBuild incorporated into SDK which hasRoslyn 4.x
. As for question from @idzikovski, try to use this command:dotnet build TestApp.iOS.csproj -t:clean -p:Configuration=Release -p:Platform=iPhone
.Thanks for the reply, this builds successfully, but it doesn't generate a binary. It seems as dotnet build ignores the properties in the csproj file such as
<BuildIpa>true</BuildIpa>
. Is there a way to configure dotnet to create the ipa file?
@idzikovski , 👋 Yes, there is a way, try to use this command: dotnet build TestApp.iOS.csproj -t:clean -p:Configuration=Release -p:BuildIpa=true -p:Platform=iPhone
. More information with other use cases can be found here.
Hi @IvanZosimov - thanks for the suggestion - unfortunately not having any luck
Here's the public repo https://github.com/InquisitorJax/Xamarin-Forms-Github-Actions
I'm guessing this entry in the project files is pointing to an incorrect path:
Hi @IvanZosimov - thanks for the suggestion - unfortunately not having any luck
Here's the public repo https://github.com/InquisitorJax/Xamarin-Forms-Github-Actions
Hi, @InquisitorJax 👋 The steps for making it work are pretty the same as in the comment https://github.com/actions/runner-images/issues/5782#issuecomment-1202815693, but for Android the path to Xamarin.Android.CSharp.targets
is different.
For iOS:
- Use this command:
dotnet build XamFormsGithubActions/App1/App1.iOS/App1.iOS.csproj -t:clean -p:Configuration=Release -p:Platform=iPhone
- Change/Add this line to your
App1.iOS.csproj
-<Import Project="/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/msbuild/iOS/Xamarin.iOS.CSharp.targets" />
For Android:
- Use this command:
dotnet build XamFormsGithubActions/App1/App1.Android/App1.Android.csproj -t:clean -p:Configuration=Release
- Change/Add this line to your
App1.Android.csproj
-<Import Project="/Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.CSharp.targets" />
Thanks for the workarounds but why .... Microsoft needs to fix this ...
@IvanZosimov that's good for the github actions build - but those project file changes will then result in the same error when trying to build the project on the local machine - the CSharp.Targes path doesn't exist on a local machine. As @stephenhauck mentions - these work-arounds (hacks) are bound to cause these kinds of issues - would be great if it "just works" . Building on my machine vs cloud image on github / pipelines shouldn't be any different.
... is there not perhaps a way to run a github action to install the CSharp.Targets to the location that the default project file import entry is expecting?
in the meantime - I implemented a work-around by copying the Release build config to a 'GitHubActions' build config, and then adding conditional inclustions in the project file:
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" Condition="'$(Configuration)'=='Debug' Or '$(Configuration)'=='Release'" />
<Import Project="/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/msbuild/iOS/Xamarin.iOS.CSharp.targets" Condition="'$(Configuration)'=='GitHubActions'"/>
@InquisitorJax Many thanks for a work around which works locally as well with github actions.
But the following command:
dotnet build -t:clean /p:Configuration=GitHubActions /p:Platform=iPhone /p:BuildIpa=true ./src/app.iOS/app.iOS.csproj
only seems to clean the project not build anything.
and if I change the command to following:
dotnet build -t:build /p:Configuration=GitHubActions /p:Platform=iPhone /p:BuildIpa=true ./src/OBD-S.iOS/OBD-S.iOS.csproj
or to
dotnet build /p:Configuration=GitHubActions /p:Platform=iPhone /p:BuildIpa=true ./src/OBD-S.iOS/OBD-S.iOS.csproj
I get this error:
/Users/runner/.dotnet/sdk/7.0.100/Microsoft.Common.CurrentVersion.targets(1229,5): error MSB3644: The reference assemblies for Xamarin.iOS,Version=v1.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
.
Do u have any insights on this?
@Umer-Mahmood-889 sorry I don't :(
Could you find a workaround for your error @Umer-Mahmood-889 ?
@ChristophWeigert Yes, I will get back to you with the solution that worked for me.
@ChristophWeigert following solution worked for me:
I added the file named: Directory.Build.props
with following contents:
<Project>
<ItemGroup>
<!--Specify Compiler for Mac Builds-->
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="4.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
Here's the project structure and location of the above mentioned file:
src/
- Demo-App/
- Demo-App.Android/
- Demo-App.iOS/
- Directory.Build.props
@Umer-Mahmood-889 Tried this in Azure DevOps with macOS 12 Image and dotnet build command. But it build fails with.
##[error]/Users/runner/.dotnet/sdk/7.0.102/Microsoft.Common.CurrentVersion.targets(1229,5): Error MSB3644: The reference assemblies for Xamarin.iOS,Version=v1.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
I'm still hopeful but this has me working on switching to Flutter because issues like this not being addressed has my customers asking for Flutter to leave Xamarin and MAUI
This says it will build Xamarin, MAUI and Flutter so I'm looking into it ...
https://codemagic.io/
Hi, all 👋 Sorry for the late response. I'm closing this issue now as we transferred it directly to the task team
. These workarounds may be helpful while the problem isn't solved:
- https://github.com/actions/runner-images/issues/5782#issuecomment-1202815693 , https://github.com/actions/runner-images/issues/5782#issuecomment-1249068405
- https://github.com/actions/runner-images/issues/5782#issuecomment-1422920694