Maui build and publication issues - maui

I have a MAUI project that references 3 .dll's that are built with netstandard2.1. I am working on a Mac with Ventura MacOS and Visual Studio 2022 17.4.2. I am having a problem building the .ipa for the iOS platform. I can compile all of the elements of the project but when I run the command
"dotnet publish -f:net6.0-ios -c:Release /p:ArchiveOnBuild=true -r:ios-arm64 --no-self-contained"
I get 3 errors all related to the .dll project files not referencing .net6.0-ios.
/usr/local/share/dotnet/sdk/6.0.404/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5):
error NETSDK1005: Assets file
'/Users/davidrutter/Projects/RadixIQDealerPortal/aspnet-core/src/RadixDealerPortal.HttpApi.Client/obj/project.assets.json'
doesn't have a target for 'net6.0-ios'.
I've tried several things and searched all over trying to find a solution but without success. If anyone has an idea how to resolve this I would be truly appreciative.

You want to use the framework net6.0, net6.0-ios should not make a difference here as you are using --no-self-contained.
Leaving the options for net6.0-ios out should work too, as you already have the runtime defined.
TLDR;
remove -f:net6.0-ios

Related

Visual Studio Code on Apple M1 chip and .NET Core 3.1

Trying to set up my dev env on my mac machine with M1. Downloaded VSCode and all required SDKs.
I am able to run any project >=6.x (because MSFT has native SDK for ARM64), but struggling in running projects that target .NET Core 3.1 for instance.
Here is what I get as an error when I try to build\run:
Architecture: arm64
Framework: 'Microsoft.AspNetCore.App', version '3.1.0' (arm64)
.NET location: /usr/local/share/dotnet/
The following frameworks were found:
6.0.7 at [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=3.1.0&arch=arm64&rid=osx.12-arm64
I have tried to run VSCode using rosseta to emulate Intel without any luck. Looks like omnisharp extension needs to be updated, but not sure what exactly to change.
Appreciate any help!
P.S. Everything works in Visual Studio, but not in vscode.
UPDATE
Adding path (/usr/local/share/dotnet/x64) to x64 in /etc/path makes the
trick, but I don't like this kind of trick, let me know guys if you have an any better solution...
Adding an answser here as well as a comment, as formatting in comments doesn't work...
I needed to edit the file
/etc/paths
to add the line:
/usr/local/share/dotnet/x64
Note that you may not see the /etc folder in Finder on the mac because it's hidden.
To see hidden files/folders in Finder, press Shift-Cmd-1
The above key combination toggles hidden folder/file visibility

Maui Blazor Hybrid - Cannot double click on the exe in the bin folder

I recently installed the preview version of visual studio and created a new .net maui blazor hybrid app.
When debugging the app, a window shows up and everything works just as expected.
However when i go to the bin folder and run the exe that is located there the window does not come up.
In the windows event logs i can see the following:
Exception Info: System.DllNotFoundException: Unable to load DLL 'Microsoft.ui.xaml.dll' or one of its dependencies
And indeed that dll is missing from the bin folder.
What does visual studio do to make this work? How can i just run the exe?
Right now we only support so-called “packaged” apps. Those you need to publish to an MSIX and install in order to run.
We’re working on adding the unpackaged scenario as well, you can track that here: https://github.com/dotnet/maui/issues/3166
While searching for the above issue I noticed a couple of others ones though. According to this and this it might already be possible right now, you might want to try!

How to fix "The type or namespace name could not be found"?

Visual studio wont recognize certain packages (Entities, and TMPro, to name a few) and it gives the error: The type or namespace name could not be found; but everything compiles fine. I know there are already many questions and answers related to this problem, but so far none of them have worked for me.
So the way I downloaded these packages was by using the Unity Package Manager, so this makes things even more confusing because I installed other packages the same way, and they are recognized no problem.
So far I have tried:
Checking the target framework of the packages and the project (all are .NET Framework 4.6)
Deleting the Library folder
Checking my Unity version (2019.2.0a11)
Some extra notes:
I've had this issue for a long time now (with TMPro to be specific; for about a year) ever since downloading it from the Package Manager in one of the 2018.X versions
In other Unity projects, which are using various versions, give the same result. This leads me to believe it is something to do with my visual studio.
The Entities package shows up on the side, see picture below
I uninstalled Visual Studio 2017 installed Visual Studio 2019 and it fixed my problem. I suspect re-installing like others suggested may have worked too.

Library not Loading/Image not Found - Swift 4.0

So I am very new to Swift and XCode. I am trying to use an external library called JJFloatingActionButton the projects build fine but when I try run it on an emulator I get:
dyld: Library not loaded: #rpath/JJFloatingActionButton.framework/JJFloatingActionButton
Referenced from: /Users/mkangwa/Library/Developer/CoreSimulator/Devices/
3E58C8A1-3F02-4CA0-8EF3-A79311A202A2/data/Containers/Bundle/Application/D8BBF9A8-5BC7-4619-
B08C-2E6F7C6BCB85/DriversHub-iOS.app/DriversHub-iOS
Reason: image not found
Now of course I know you can't come ask a question like this on StackOverflow without researching and trying to find a solution yourself, so thats what I've been doing for the past few hours I have been looking at what was causing this, I started thinking that maybe it was the library it's self so this one is the third or fourth I've tried till I came across a few posts on SO that were about this issue.
Most people fixed this by just putting the Framework into the Embedded Binaries in the targets General Settings. And I tried this but I now receive a log:
I also get a Dependancy Analysis Warning:
I don't know much about these types or warning and errors but it's saying that it can't find the file which is pretty self explanatory but when I am adding the file to Embedded Binaries it shows the framework file there
What I often do when I have problems with cocoapods is remove cocoapods from the project and reinstall it.
You could use pod deintegrate (https://github.com/CocoaPods/cocoapods-deintegrate) to remove it and then a pod install to reinstall.
So it took a day and a half to work this out but I have finally got it and I can carry on with my project.
Problem:
The problem in my particular case (because other methods seemed to have worked for people trying to achieve the same thing) that the reason my project wouldn't build and was throwing Build Time errors was because after adding the Framework to Embedded Binaries it was also adding it to Embed Frameworks in my targets Build Phases. This then, I believe, caused the compiler to try and build it twice hence the Multiple Build Commands error
Solution:
So the errors I kept getting where saying No such file or directory above it was saying Multiple build commands for output file and what I did to fix this I went to Build Phases in my target settings and deleted the framework from Embedded Frameworks but made sure it was still under [CP] Embed Pods Frameworks.
in my case I was have to make framework "embed & sign" in stead of "don't embed"

AutoMapper 6.2.2 restore fails on VSTS build server

The Restore step fails in my build definition with this error:
error NU1100: Unable to resolve 'AutoMapper (>= 6.2.2)' for '.NETCoreApp,Version=v2.0'.
This is in a .NETCoreApp 2.0 that is using AutoMapper. Restore succeeds locally in VS 2017. Locally I am using dotnet sdk 2.0.0, and nuget 4.3.1. On the VSTS (cloud) server, I am specifying the latest nuget version, 4.5.0. I have tried many other versions, including 4.3.1 with no success.
I know there is an older, similar question here, but that was never answered satisfactorily, in my opinion.
If I look at the meta data in VS, at the top of one of the Automapper files I can see this:
Assembly AutoMapper, Version=6.2.2.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005
// C:\Users\randyg.nuget\packages\automapper\6.2.2\lib\netstandard1.3\AutoMapper.dll
From this you can see it's taking the netstandard1.3 version, which is correct. I'm wondering if the nuget on the build server is looking for a netcoreApp2.0 folder, rather than the netstandard1.3 folder? Following this theory, I tried adding this to my .csproj file:
<AssetTargetFallback>$(AssetTargetFallback);netstandard1.3</AssetTargetFallback>
My theory was this would tell nuget to look for a netstandard1.3 version of automapper if it couldn't find a netcoreapp2.0 version. However, this didn't have any effect. I later read that behind the scenes this fallback is already added automatically.
If anyone has any ideas I would greatly appreciate it. I'm pulling out (what's left of) my hair on this, as this is the only package giving me trouble, and it's a critical one for my project.
On the build server I'm using .NET Core sdk 2.0.3 as well, if that matters.
This is how I solved this: since it seemed it might have to do with my target being netcoreapp2.0, I tried adding an additional 'dummy' project to my solution, with its target = netstandard1.3. In this configuration, the restore/build succeeded. I thought I would have to maintain this dummy project for this purpose, until I tried deleteing it and now the netcoreapp2.0 solution still restores fine without it. I can only assume something was corrupted in the TFS build server NPM cache (even though I had tried checking the box to disable that cache), and once I got it to succeed once, it has cleared up whatever the issue was.