Reputation: 117
Have been struggling with this for a while and all workarounds that works for other people DOESN'T work for me.
When I Publish a .Net MAUI app, I get the following error.
1>Assets file 'C:\Users\potgi\source\repos\Stax_MAUI\StaxDAL\obj\project.assets.json' doesn't have a target for 'netstandard2.0'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project.
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
========== Publish completed at 19:08 and took 18.535 seconds ==========
========== Package: 0 succeeded, 1 failed ===========
I have 3 projects in my solution:
Now the step by step PUBLISH process:
Visual Studio Information:
Microsoft Visual Studio Community 2022
Version 17.9.2
VisualStudio.17.Release/17.9.2+34622.214
Microsoft .NET Framework
Version 4.8.09037
Installed Version: Community
Visual C++ 2022 00482-90000-00000-AA845
Microsoft Visual C++ 2022
ADL Tools Service Provider 1.0
This package contains services used by Data Lake tools
ASA Service Provider 1.0
ASP.NET and Web Tools 17.9.197.37128
ASP.NET and Web Tools
Azure App Service Tools v3.0.0 17.9.197.37128
Azure App Service Tools v3.0.0
Azure Data Lake Tools for Visual Studio 2.6.5000.0
Microsoft Azure Data Lake Tools for Visual Studio
Azure Functions and Web Jobs Tools 17.9.197.37128
Azure Functions and Web Jobs Tools
Azure Stream Analytics Tools for Visual Studio 2.6.5000.0
Microsoft Azure Stream Analytics Tools for Visual Studio
C# Tools 4.9.0-3.24121.1+a98c90d56455379836dd5c845b35fa932b00cfa3
Can anyone help me, please.... I have tries .Net 6.0, .Net8 and .Net MAUI Class Libraries as well, but I get the same error (The target framework just change). Publish worked fine until a Visual Studio update (Can't remember witch one, but it was about the time of the .Net 8 release.
Upvotes: 0
Views: 449
Reputation: 4332
I have 3 projects in my solution:
- .NET MAUI project
- .NET Standard 2.0 Class Library Project
- Web API project (Don't think this is relevant to publish issue)
NET MAUI project .csproj This project references the .NET Standard Class Lib with the shared Models. The Web API project also references this project for the models.
I found a similar issue on Maui Github: Unable to archive app if it references a .NET Standard 2.0 class library #11906 and this comment in the issue:
Has anyone got a fix/workaround for this? It seems incredible that such a showstopping issue remains unaddressed. It's trivial to reproduce:
- In Visual Studio Mac, create blank MAUI app.
- Add new class library project targeting .NET Standard 2.0 to solution.
- Add a project reference to the class library project to the MAUI project.
Archive for Publishing now fails.
One difference is that he is VS Mac. But he hasn't returned to reply since then.
You can report the problem on issue of MAUI GitHub. This may be related to Regarding .NET 8, currently it still has many issues.
Upvotes: 0