How do I publish an Android app in VS2022? I've started with the "Android Application (Preview)" template. It all runs fine in emulator. When clicking publish on the project only a *.nupgk is created. When clicking "View archives..." solution shows up but the only text is "No archive builds available" and I don't see any option to create one.
Edit: By publish I mean create *.apk that could be installed. I have no need to publish to Google Play or any other store.
Update
I have created guides now for each platform with what does and doesn't work and how to proceed with publishing on the .NET MAUI repository. Find the links here:
Android
iOS
Windows
Original answer:
As pointed out in the comments, I have been playing with this and I always got all the things complete and create some content, but not quite yet.
First; this is not possible at the time or writing from the UI. Of course this will be before .NET MAUI will be released, but for the time being you'll need the command-line, specifically dotnet publish.
You've already figured out that this command typically is used to create a nupkg, but to unify all the things, this is now also going to be used to publish your .NET MAUI apps.
The problem is that we now have a single-project that can be used for all kinds of targets: iOS, Android, Windows, macOs, so how do we know what dotnet publish should publish?
You'll need to specify the target framework. For Android that brings us to this:
dotnet publish -f:net6.0-android -c:Release
This should produce an APK that you can use. The one thing I'm not sure about yet is how to add your keystore file in the mix and actually sign it properly for use in the Play Store.
To make things complete, for iOS the command and process is a bit more complicated. The command, from Windows, would look more like this:
dotnet publish -f:net6.0-ios -c:Release /p:ServerAddress=192.168.1.77 /p:ServerUser=jfversluis /p:TcpPort=58181 /p:ArchiveOnBuild=true /p:_DotNetRootRemoteDirectory=/Users/{your username}/Library/Caches/Xamarin/XMA/SDKs/dotnet/
There are a couple of parameters that are only needed when you build from Windows: /p:ServerAddress={Mac build host IP address} /p:ServerUser={Mac username} /p:TcpPort=58181 if you have never connected to this build host you should also add /p:ServerPassword={your password}. However, you could just go into Visual Studio, connect to the build host from there once and you'll know the connection works and the omit the password parameter. More on the Mac build host functionalities is here.
But we're not there yet! In the csproj file we need to add a little piece to add the RuntimeIdentifier and a couple of things to make the signing of the IPA file work.
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
<CodesignEntitlement>Entitlements.plist</CodesignEntitlement>
<CodesignKey>Apple Development: Gerald Versluis (BLABLAID)</CodesignKey>
<CodesignProvision>VS: WildCard Development</CodesignProvision>
</PropertyGroup>
The Entitlements.plist file is not part of the default templates (yet) so just take one from a Xamarin.Forms project, it can be the default one or, of course, configure it if you actually need it, but it seems you need it to be there either way.
The values for the code signing you need to get from the Apple certificates stuff. This is the part I'm not completely clear on yet as well. More info on code signing and provisioning is here, that might help get you further.
For the iOS command, also have a look at the backstory here. As seen in this link, you might also need to delete the LaunchScreen.xib file from the Platforms/iOS/Resources folder and potentially include the /p:EnableAssemblyILStripping=false flag to the publish command to work around some bugs. Both of them are fixed but not yet released.
Disclaimer: I haven't published anything to a store yet so there might be gaps here, feel free to add some comments with your findings.
Related
I have been working on a .Net Maui app to replace a Python app I built for my company's payroll team. Several previous iterations of this app have allowed me to publish via sideloading. However, I have been unable to publish a new version for a couple of days now.
If I try to publish via sideloading, I get the following error:
MSB4057 The target "_GenerateAppxPackage" does not exist in the
project.
--this error claims to be stemming from line 1 of my .csproj file.
I attempted another route to publish it as an executable file following the answer provided in this stack overflow answer, and received the following error:
C:\User\MyFirstName : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.
As well as another error that says looking for the manifest existed with a code 31.
Further up, before that error hits, there is a line that says:
Skipping target "MauiGeneratePackageAppxManifest" because all output
files are up-to-date with respect to input files.
I am running VS 17.4.0 Preview 3.0 on Windows 11. I have tried to roll back my code through git (up to 3 versions back), as well as copying local files into a new project, and I get these same errors every time.
It may also be worth mentioning that my Windows Defender and Windows Malicious Software Removal Tool both updated between when I was last able to publish successfully and when the problem arose. I had also updated Visual Studio, but tried to roll that back and publish, and it received the same errors.
Is there anyone who can help me figure out what is going on here, or point me in the right direction? I can provide code samples if need be, though on a limited basis because this is a private project.
For this, you can refer to document : Publish a .NET MAUI app for Android/IOS/Windows.
Above documents explain the steps to publish android, ios and windows app, respectively.
You can follow the steps step by step. Under normal circumstances, there will be no problem.
Whenever I try to start the HelloMaui project from VS Code using NET 6.0.100 Preview4 with mono debug extension installed and run it it throws an error Xamarin.Android.Common.Debugging.targets(604,5): error XA0010: No available device. I wonder if anyone had a problem running the sample project?
The same bug has been reported 3 days ago in the official repo https://github.com/dotnet/maui/issues/1197, as MAUI still in an early stage it better to follow on the official repo.
Try to ensure that the emulator is ready before debugging the app (build+deploy), by starting it manually.
Not sure how to do it from vs code but probably will be common for command line:
Navigate to C:\*\Android\android-sdk\emulator
emulator -list-avds
You should see at least one emulator name otherwise you need to install one.
emulator.exe -avd NameOfYourEmulator -partition-size 512 NameOfYourEmulator taken from the previous step.
Docs
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/command-line-emulator
Edit
If the returned list of Android device emulators is empty (from step 2) and you are sure you have at least one emulator previously added/installed then try unloading and reloading the android project.
If you are not sure, you may open Android device manager from visual studio and check the listed devices there, if empty then you need to add at least one.
Related issue Maui-check fails on Android Emulator Setup
I have to build android app using Unity 2018.4.9f1 with App Bundle (Google play) and I get this error. When building normal apk everything is working fine.
1 exception was raised by workers:
com.android.tools.build.bundletool.exceptions.BundleFileTypesException$FileUsesReservedNameException: File 'root/res/drawable-hdpi/ic_launcher.png' uses reserved file or directory name 'res'.
Tried diffrent unity versions. Tried deleting this file (but looks like it's hidden somewhere or generating during gradle compile)
I'm using Unity 2019.4.0f1 and got stuck in the same error. Here's what I've found on internet and solved.
(you probably got a solution, but it's good for those who will see this post)
Open your project settings > Player > Other Settings, loko for configuration, make sure you ticked this options below:
Player setup
Scripting Backend IL2CPP
Enable ARMv7, ARM64, Split APKs by target architecture
Then in your Build Settings
Build settings setup
Just default values (unity 2019.4 version).
Hope that helps someone :)
[edit 1]
I know this doesn't fix the android bundle app build, I think that's an unity bug, not sure, however this should work fine on google play console (worked for me)
I am having problems with a build server that I am trying to set up.
We use telerik, and have installed the libraries with the telerik control panel. The build process searches for the dll's all the wrong places.
Needless to say that the solutions builds perfectly on developer maschines.
The solution contains many projects, and not a single main project. I really do not want to have to change all the proj-files.
What I want is to add the telerik directory to AssemblySearchPaths, but using the msbuild parameters from the gui only got me to overwrite the AssemblySearchPath - with the result that the location of everything else but telerik files became unknown to build.
So I located a .targets file, which I read in the logfiles were utilized by build to set AssemblySearchPaths. And adding the telerik directory here did the trick (alas I still cannot get the build server to find the nuget dll's but that is another story).
However, I see that depending on selected CPU and perhaps other circumstances, the build uses another similar named .targets file from another location. Also, I find it less than optimal that such crutial customization is hidden away in a automatically installed file somewhere obscure.
So the question is: how to add more searchpaths to the ones already defined by the framework?
I am somewhat unfamiliar with ms build, but I did see an full fledged ms build file once which is why I knew it defines the build searh paths. However; alternatives which does not require that I change the projects in the solution will work for me.
Thanks!
Firstly, you need to be clear that: when you queue a build in VSO, the queued build is running on the Hosted Build Server. However, the software environment is different than developer machines, that is the reason why you can build successfully on developer machine but not on hosted build server.
If you would like, one easier way to resolve your issue is to set up the developer machine as the build server. You can register that developer machine with VSO, then all builds will run directly on the developer machine. Check this MSDN article for the details on how to set up build controller: https://msdn.microsoft.com/library/ee330987.aspx
If you don't like to set up the on-premise build server for VSO, you need to use Nuget restore function to resolve the assembly reference issue, because as far as I can tell configuring AssemblySearchPaths is not so convenient. Please check link for the details on how to have NuGet packages restored during the VSO (TFS) build process: http://docs.nuget.org/consume/package-restore/team-build
We are using Windows Azure to host our application on a Cloud Service and use Powershell to build and package the website using msbuild.
On releasing our first response time is very slow so naturally we'd need to precompile the application.
There's plenty of documentation for Precompiling using the aspnet_compiler, however I cannot find any official documentation on using:
msbuild Web.sln /p:PrecompileBeforePublish=true
A Google search targeted at MSDN gives me nothing whilst usually MSDN is fairly thorough. All I can see is a useful Stack post from earlier this year.
So does anyone know of any formal documentation for PrecompileBeforePublish? Am I looking at the wrong source?
Failing that, what exactly does the flag provide us, is it the same as Precompilation for Deployment with an Updatable UI (reference)?
It's been a while since this question was posted and there is still no good answer. Recently I wanted to change the way MSBuild runs aspnet_compiler.exe but found no documentation. I did a bit of digging around and here is my experience.
Precompiling will only happen if you use both the DeployOnBuild and PrecompileBeforePublish parameters. Other usable parameters are EnableUpdateable and UseFixedNames.
msbuild Web.sln /p:DeployOnBuild=true /p:PrecompileBeforePublish=true /p:EnableUpdateable=false /p:UseFixedNames=true
You can achieve a similar result if you change precompile options in Visual Studio. This can be done at Project > Publish > Configure > Settings > File Publish Options > Precompile during publishing > Configure.
link to image
This is how the parameters should appear in your .pubxml file:
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>False</EnableUpdateable>
<DebugSymbols>True</DebugSymbols>
<WDPMergeOption>CreateSeparateAssembly</WDPMergeOption>
<UseFixedNames>True</UseFixedNames>
Since there is no documentation to be found you might want to change these options and see the resulting .pubxml file to see what further parameters to use in the command line.
I think, your problem is not pre-compilation and I see, you have done precompiling well.
I think your project is too big (Check your final bin directory size) IIS read every dll, and debug symbols and load them in to memory before running any line of code.
If your project size too big, and your virtual environment resorces are low, magnetic disk, low ram, low cpu, so there is no magic in it.
Recommendations:
Try to reduce size of the project output. (Removing debug symbols
can be an option).
Remove all not used references... (Both .net and 3rd Party) (edit, added)
Scale up your environment configuration.
Regards...
rex the solution to your problem is, add a new web deployment project for your website which will automatically pre-compile your website and the project will contain pre-compiled web outputs. If you don't get the web deployment project in your right click please download the tool for Visual Studio with respect to either 32 or 64 bit which will be added to your visual studio Or if you want to do it through MS Build you need to refer to https://msdn.microsoft.com/en-us/library/ms227972.aspx or you can also refer to http://www.asp.net/web-forms/overview/older-versions-getting-started/deploying-web-site-projects/precompiling-your-website-vb
I hope I helped you in some way.