Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MAUI Project not running on Windows

Tags:

c#

.net

maui

I have a MAUI project which I am targetting for iOS and Android, however I previously usd the "Windows Machine" option as ti allowed for quicker debugging than any of the terrible emulators or the hassle of setting up the real devices. However, when it came time to start packaging and publiching, I found I needed to disable each project I was not publishing, so I unchecked the "Target Windows" in the Project file.

Now, when I try and renable this I get this message.

Error NETSDK1005 Assets file 'C:\source\RackEmAppMobile\RackEmAppMobile\obj\project.assets.json' doesn't have a target for 'net8.0-windows10.0.22621.0'. Ensure that restore has run and that you have included 'net8.0-windows10.0.22621.0' in the TargetFrameworks for your project. RackEmAppMobile C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 266

I have tried cleaning and rebuilding, reloading the project etc. If I delete the obj folder all it does is give me the same error plus an error for every other target framework.

Help!

like image 235
Matthew Warr Avatar asked Dec 05 '25 13:12

Matthew Warr


1 Answers

There must have been something very wrong with the csproj file. I ended up having to create a new blank project and copy all my files back in over the top. At which point once I fixed up all the other errors you’d expect to see it runs perfectly.

The one thing I will say, is that if using a Visual Studio, after switching targets, restart VS. It seems to recompile the csproj file when you do this. One thing I know I was doing was switching targets, getting target errors and then trying to fix it. Restarting VS seems to be a better approach.

I have now reverted to VS Code which I run on Mac. Whilst I have had to learn to embrace the command line, connectivity to emulators, target switching etc is a much better experience. It still has some intellisense issues but at least I can build and run the damn thing rather than the days I was losing trying to get it to compile.

Hope this is useful to someone

like image 74
Matthew Warr Avatar answered Dec 08 '25 03:12

Matthew Warr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!