Share via

Referncing a universal windows project from console app.

30602091 21 Reputation points
2022-11-01T09:22:40.56+00:00

Hi,
I created a console app ("MyConsoleApp" - which is not a universal windows console app!) that references to a universal windows project. ("MyUWPProject")
I have a run.bat file that contains
** msbuild MyApp.sln /m:4 /target:code\MyConsoleApp**
When i execute my .bat file i get the following error:

: error NU1201: Project MyUWPProject is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Project MyUWPProject supports
: uap10.0.18362 (UAP,Version=v10.0.18362)

How can fix this?
Is what I'm doing even possible?
Thanks an advance!
Yael,

Developer technologies | Universal Windows Platform (UWP)

1 answer

Sort by: Most helpful
  1. Junjie Zhu - MSFT 21,746 Reputation points
    2022-11-17T09:59:16.393+00:00

    Hi @30602091 ,
    Welcome to Microsoft Q&A!

    The error message shows that the environment of your .NET 6.0 project is .net6.0 and the environment of the UWP project doesn't support .net6.0. So the UWP project is not compatible with the .NET project.

    If you want to use Windows Runtime APIs, you could just make some confirugation in for your .NET 6.0 porject so that you could directly call Windows Runtime APIs in your app. You will need to Edit Your Project File and Modify TargetFramework Element to net6.0-windows10.0.19041.0.

    You could check this document - Call Windows Runtime APIs in desktop apps for detailed steps.

    Thank you,
    Junjie

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.