Open Alex-Dobrynin opened 3 years ago
C# 9 was released in November, it's now 5 months later and this is still not supported?
It looks like #86
Bump? How is it possible that Microsoft's own tools don't support their own language? Setting project version to latestmajor fails to compile on AppCenter with C# 9 features.
Any update? I still have the same issue.
I had to switch to Azure DevOps builds because of this issue.
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.
Keep alive. This is still an issue.
The AppCenter support team pointed me to an article by Jean-Marie Alfonsi for a workaround: https://www.sharpnado.com/build-c-9-with-appcenter/
Here's what's working for me right now:
Android build (Xamarin.Android 11.2)
#!/usr/bin/env bash
echo "Pre-build script executing..."
# Add support for C#9
MonoFrameworkPackage=MonoFramework-MDK-6.12.0.154.macos10.xamarin.universal.pkg
wget https://download.mono-project.com/archive/6.12.0/macos-10-universal/$MonoFrameworkPackage
sudo chmod +x $MonoFrameworkPackage
sudo installer -pkg $MonoFrameworkPackage -target /
iOS build (Xamarin.iOS 14.20, Xcode 13.0)
#!/usr/bin/env bash
echo "Post-clone script executing..."
# Update nuget (fix NETSDK1005)
sudo nuget update -self
#!/usr/bin/env bash
echo "Pre-build script executing..."
# Add support for C#9
MonoFrameworkPackage=MonoFramework-MDK-6.12.0.154.macos10.xamarin.universal.pkg
wget https://download.mono-project.com/archive/6.12.0/macos-10-universal/$MonoFrameworkPackage
sudo chmod +x $MonoFrameworkPackage
sudo installer -pkg $MonoFrameworkPackage -target /
Wow fantastic thank you!! Still no official support and C# 10 just around the corner......!!
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.
Bump to keep open
Similar problem with C# 10
I'm having the same issue with C# 10 and MAUI.
Here's my script so far, but it's still failing to execute the nuget script. I overwrote the nuget.exe under /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/nuget/ and made sure the nuget symbolic link point to the script file which has this content:
#!/bin/sh
exec /Library/Frameworks/Mono.framework/Versions/6.12.0/bin/mono $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/nuget/nuget.exe "$@"
This is the error I get:
Invoking nuget.exe with --version returns:
Unknown command: '--version'
NuGet.Commands.CommandException: Unknown command: '--version'
at NuGet.CommandLine.CommandManager.GetCommand (System.String commandName) [0x0004e] in <628ad472b621437fba78dcacbf4e1cd2>:0
at NuGet.CommandLine.CommandLineParser.ParseCommandLine (System.Collections.Generic.IEnumerable1[T] commandLineArgs) [0x00016] in <628ad472b621437fba78dcacbf4e1cd2>:0
at NuGet.CommandLine.Program.MainCore (System.String workingDirectory, System.String[] args) [0x0012b] in <628ad472b621437fba78dcacbf4e1cd2>:0
Here's my post-clone script so far:
#!/usr/bin/env bash
wget https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh
chmod +x dotnet-install.sh
./dotnet-install.sh --channel Current --install-dir "$AGENT_TOOLSDIRECTORY/dotnet"
echo "Install required workloads"
$AGENT_TOOLSDIRECTORY/dotnet/dotnet workload install maui-android
$AGENT_TOOLSDIRECTORY/dotnet/dotnet workload install ios
echo "Download Latest Mono Preview"
wget https://download.mono-project.com/archive/mdk-latest-preview.pkg
echo "Add execution permission"
sudo chmod +x mdk-latest-preview.pkg
echo "Install Latest Mono Preview"
sudo installer -pkg mdk-latest-preview.pkg -target /
echo "Get latest Nuget"
wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
echo "overwrite old nuget in Mono 6.12.0"
sudo cp -f -R nuget.exe /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/nuget/
echo "Recreate the symbolic link"
sudo ln -s /Library/Frameworks/Mono.framework/Versions/Current/Commands/nuget nuget
echo "Try invoking --version switch"
exec /Library/Frameworks/Mono.framework/Versions/6.12.0/bin/mono $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/nuget/nuget.exe "--version"
echo "Attempt fix itself"
exec /Library/Frameworks/Mono.framework/Versions/6.12.0/bin/mono $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/nuget/nuget.exe "update -self"
echo "MSBuild restore start"
MSBuild /Users/runner/work/1/s/Supervisor.DotnetMaui/One37.Supervisor.Maui.csproj -t:restore
echo "MSBuild restore finish"
I'm having the same issue with C# 10 and MAUI.
Here's my script so far, but it's still failing to execute the nuget script. I overwrote the nuget.exe under /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/nuget/ and made sure the nuget symbolic link point to the script file which has this content:
#!/bin/sh exec /Library/Frameworks/Mono.framework/Versions/6.12.0/bin/mono $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/nuget/nuget.exe "$@"
This is the error I get:
Invoking nuget.exe with --version returns: Unknown command: '--version' NuGet.Commands.CommandException: Unknown command: '--version' at NuGet.CommandLine.CommandManager.GetCommand (System.String commandName) [0x0004e] in <628ad472b621437fba78dcacbf4e1cd2>:0 at NuGet.CommandLine.CommandLineParser.ParseCommandLine (System.Collections.Generic.IEnumerable1[T] commandLineArgs) [0x00016] in <628ad472b621437fba78dcacbf4e1cd2>:0 at NuGet.CommandLine.Program.MainCore (System.String workingDirectory, System.String[] args) [0x0012b] in <628ad472b621437fba78dcacbf4e1cd2>:0
Here's my post-clone script so far:
#!/usr/bin/env bash wget https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh chmod +x dotnet-install.sh ./dotnet-install.sh --channel Current --install-dir "$AGENT_TOOLSDIRECTORY/dotnet" echo "Install required workloads" $AGENT_TOOLSDIRECTORY/dotnet/dotnet workload install maui-android $AGENT_TOOLSDIRECTORY/dotnet/dotnet workload install ios echo "Download Latest Mono Preview" wget https://download.mono-project.com/archive/mdk-latest-preview.pkg echo "Add execution permission" sudo chmod +x mdk-latest-preview.pkg echo "Install Latest Mono Preview" sudo installer -pkg mdk-latest-preview.pkg -target / echo "Get latest Nuget" wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe echo "overwrite old nuget in Mono 6.12.0" sudo cp -f -R nuget.exe /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/nuget/ echo "Recreate the symbolic link" sudo ln -s /Library/Frameworks/Mono.framework/Versions/Current/Commands/nuget nuget echo "Try invoking --version switch" exec /Library/Frameworks/Mono.framework/Versions/6.12.0/bin/mono $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/nuget/nuget.exe "--version" echo "Attempt fix itself" exec /Library/Frameworks/Mono.framework/Versions/6.12.0/bin/mono $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/nuget/nuget.exe "update -self" echo "MSBuild restore start" MSBuild /Users/runner/work/1/s/Supervisor.DotnetMaui/One37.Supervisor.Maui.csproj -t:restore echo "MSBuild restore finish"
Did you ever get this working? I'm running into the same issues trying to build my projects in AppCenter that target C# 10. I tried using the scripts posted by @pmarienfeld with the latest preview of Mono but no luck.
No. I switched my project back to Xamarin.
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.
Bump to prevent stale.
PLEASE Microsoft. PLEASE just add support for C#9 & 10. I really don't want to have to go back to C# 8 and I really don't want to spend my time setting up pipelines in some other CI.
I love AppCenter, I want to be able to use it for my team's entire workflow.
Is there any communicated target date for AppCenter to support C#9 ?
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.
Any plans on supporting C#10 on MS App Center? The build is still breaking and we cannot migrate just yet.
Still experiencing this issue on C#10
The same issue with c#10. Any workarounds available?
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.
bump
does appcenter work at all with Maui? it uses obviously very old build agents dont even support .net 10 yet
.
After much research, I found a way to support C# 10 in App Center. Checked with iOS and Android builds.
I tested it with netstandard2.1 project with <LangVersion>10.0</LangVersion>
setting in the csproj file.
In short, the hack is to force using msbuild from Visual Studio for Mac, not from mono.
Add the following to the 'appcenter-pre-build.sh' file. New Mono installation is not required, works with Xamarin.iOS 16.1 in App Center.
# Use msbuild from Visual Studio
msBuildMonoPath='/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/15.0/bin/MSBuild.dll'
msBuildVSforMacPath='/Applications/Visual\\ Studio.app/Contents/MonoBundle/MSBuild/Current/bin/MSBuild.dll'
# Use msbuild from Visual Studio
sudo sed -i '' "s#$msBuildMonoPath#$msBuildVSforMacPath#" /Library/Frameworks/Mono.framework/Commands/msbuild
In theory, it can be possible to use msbuild from .NET 6+ SDK, thus supporting MAUI and .NET 6+. I'll check further and provide more details.
Using several hacks and the power of the post-clone script, I was able to build a NET MAUI app (with .NET 7) using App Center. I haven't tested publishing to App Stores, so it's unclear whether it's usable or not :)
@pfedotovsky could you provide the instruction and scripts how to run maui build in appcenter? also does it work only with ios or with android too?
@Alex-Dobrynin The solution will work with iOS and Android. I currently tested iOS builds, including publishing the Release build (*.ipa file) directly to TestFlight. But a similar approach can be done for Android apps as well.
The trick is to bypass AppCenter build altogether and do the build in the appcenter-post-clone.sh Then you have to disable AppCenter's nuget/msbuild commands, I did so by modifying their executable files; see below:
#!/usr/bin/env bash
echo "Post-clone script executing..."
export DOTNET_NOLOGO=true
dotnet --info
echo "Build configuration: $APPCENTER_XAMARIN_CONFIGURATION"
# Install MAUI workloads
dotnet workload restore
# Build the app (iOS Simulator)
# dotnet build --configuration $APPCENTER_XAMARIN_CONFIGURATION
# Create release ipa for devices
dotnet publish -f:net7.0-ios -c:Release /p:ArchiveOnBuild=true /p:RuntimeIdentifier=ios-arm64 /p:CodesignKey="$APPLE_CERTIFICATE_SIGNING_IDENTITY" /p:ApplicationVersion=$(date +%s)
# Use dummy msbuild
echo """#!/bin/sh
echo $(msbuild /version /nologo)
""" | sudo tee /Library/Frameworks/Mono.framework/Commands/msbuild
# Use dummy nuget
echo """#!/bin/sh
echo Dummy Restore
""" | sudo tee /Library/Frameworks/Mono.framework/Commands/nuget
I created a test repo; see here: https://github.com/pfedotovsky/maui-appcenter. I plan to update it with more details later, but meanwhile, you can contact me directly. Of course, this approach has several drawbacks (using sudo, for instance), but as Proof-of-Concept, it's working.
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.
Microsoft please fix!
Please!!!! 🙏🙏🙏🙏🙏
bump
Bump
Just discovered App Center today, upgrading our Xamarin apps to MAUI, only to find that App Center doesn't support MAUI. Very disappointing, seeing as Xamarin is EOL in May.
When building Xamarin forms app which consumes c#9 AppCenter fails build with this error
CSC : error CS1617: Invalid option '9.0' for /langversion. Use '/langversion:?' to list supported values.
But I can successful build locally on my PC or macOS