Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build with new monogame project #8

Open
Ma11ock opened this issue Oct 25, 2023 · 5 comments
Open

Cannot build with new monogame project #8

Ma11ock opened this issue Oct 25, 2023 · 5 comments

Comments

@Ma11ock
Copy link

Ma11ock commented Oct 25, 2023

I tried your library with the latest monogame in visual studio 2022, but the projects refuse to build. Here is the output for the test project I tried making:

Severity	Code	Description	Project	File	Line	Suppression State
Error	MSB3073	The command "dotnet C:\Users\DankM\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\\..\tools\netcoreapp3.1\any\mgcb.dll /quiet /@:"C:\Users\DankM\source\repos\Erm\MGUI\MGUI.Shared\Content\MGUI.Shared.Content.mgcb" /platform:DesktopGL /outputDir:"C:/Users/DankM/source/repos/Erm/MGUI/MGUI.Shared/Content/bin/DesktopGL/MGUI.Shared.Content" /intermediateDir:"C:/Users/DankM/source/repos/Erm/MGUI/MGUI.Shared/Content/obj/DesktopGL/MGUI.Shared.Content" /workingDir:"C:/Users/DankM/source/repos/Erm/MGUI/MGUI.Shared/Content/"" exited with code -2147450730.	MGUI.Shared	C:\Users\DankM\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\MonoGame.Content.Builder.Task.targets	138	
Error	MSB3073	The command "dotnet C:\Users\DankM\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\\..\tools\netcoreapp3.1\any\mgcb.dll /quiet /@:"C:\Users\DankM\source\repos\Erm\Erm\Content\Content.mgcb" /platform:DesktopGL /outputDir:"C:/Users/DankM/source/repos/Erm/Erm/Content/bin/DesktopGL/Content" /intermediateDir:"C:/Users/DankM/source/repos/Erm/Erm/Content/obj/DesktopGL/Content" /workingDir:"C:/Users/DankM/source/repos/Erm/Erm/Content/"" exited with code -2147450730.	Erm	C:\Users\DankM\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\MonoGame.Content.Builder.Task.targets	138	
Error	MSB3073	The command "dotnet C:\Users\DankM\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\\..\tools\netcoreapp3.1\any\mgcb.dll /quiet /@:"C:\Users\DankM\source\repos\Erm\MGUI\MGUI.Core\Content\MGUI.Core.Content.mgcb" /platform:DesktopGL /outputDir:"C:/Users/DankM/source/repos/Erm/MGUI/MGUI.Core/Content/bin/DesktopGL/MGUI.Core.Content" /intermediateDir:"C:/Users/DankM/source/repos/Erm/MGUI/MGUI.Core/Content/obj/DesktopGL/MGUI.Core.Content" /workingDir:"C:/Users/DankM/source/repos/Erm/MGUI/MGUI.Core/Content/"" exited with code -2147450730.	MGUI.Core	C:\Users\DankM\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\MonoGame.Content.Builder.Task.targets	138

I even tried downgrading the monogame version in the main project to match the mgui version, but still no luck. I also tried fiddling with the .NET core versions, again no luck.

Any help would be great!

@Videogamers0
Copy link
Owner

MGUI targets .NET 6.0, not .NET Core. Maybe that's related to the issue? Make sure you have downloaded and installed the .NET 6.0 sdk.

Also MGUI intentionally uses an older version of monogame.content.builder.task since I ran into some issues with text rendering on the newer versions (which might be fixed by now in the latest version, so you could try updating that nuget package).

If the older version of mgcb isn't opening, try this. You might also need to run the command dotnet tool install -g dotnet-mgcb-editor idk

@Muhammadinaam
Copy link

I set target framework to net6 instead of net6-windows. Following is the error.

Severity Code Description Project File Line Suppression State
Error NETSDK1136 The target platform must be set to Windows (usually by including '-windows' in the TargetFramework property) when using Windows Forms or WPF, or referencing projects or packages that do so. One C:\Program Files\dotnet\sdk\7.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets 250

@Videogamers0
Copy link
Owner

Videogamers0 commented Mar 8, 2024

I set target framework to net6 instead of net6-windows. Following is the error.

Severity Code Description Project File Line Suppression State Error NETSDK1136 The target platform must be set to Windows (usually by including '-windows' in the TargetFramework property) when using Windows Forms or WPF, or referencing projects or packages that do so. One C:\Program Files\dotnet\sdk\7.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets 250

Works fine for me. I tried the following:

  1. Open MGUI.Samples.csproj in any text editor and change <TargetFramework>net6.0-windows</TargetFramework> to <TargetFramework>net6.0</TargetFramework>. Save and close.
  2. Open MGUI.Core.csproj and do the same change as above.
  3. Open MGUI.sln in Visual Studio 2022 and run the MGUI.Samples project

I'm on Windows PC.

Did you change the target framework on both projects? MGUI.Core.csproj has a condition to enable/disable the UseWPF setting depending on the TargetFramework:

<PropertyGroup Condition=" $(TargetFramework.EndsWith('windows')) ">
    <UseWPF>True</UseWPF>
    <DefineConstants>$(DefineConstants);UseWPF</DefineConstants>
</PropertyGroup>

If for whatever reason, that condition isn't working, then just remove that property group and manually set UseWPF to false in the project properties.

@rufreakde
Copy link

why not use

    <TargetFramework>net6.0</TargetFramework>

as default instead of -windows version? If the windows functionality is not really needed?

@Videogamers0
Copy link
Owner

Videogamers0 commented Jun 24, 2024

why not use

    <TargetFramework>net6.0</TargetFramework>

as default instead of -windows version? If the windows functionality is not really needed?

There are some differences in the code when targeting net6.0 instead of net6.0-windows. The main difference is that the project uses Portable.Xaml for things like parsing Xaml strings, since namespaces such as System.Windows.Markup and System.Windows.Data are not part of net core. A side effect of this is that some of the intellisense for xaml markup extensions does not seem to work in the Visual Studio XAML Designer (at least not for me) when the target platform is not set to Windows. Though oddly enough, it seems to work fine at runtime.

Also, there are several minor differences in how Data Binding is implemented. You can search the repository for #if UseWPF to see all of the differences. In particular, net6.0-windows uses System.ComponentModel.PropertyChangedEventManager to listen for changes to property values when data bindings are configured. Since that's not available in net core, I wrote my own simple implementation but I never quite got around to refactoring it to use weak event listeners so there may be (minor) memory leaks with the data binding engine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants