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

Error loading/configuring a C# .net project #1865

Open
Farravid opened this issue Apr 25, 2022 · 4 comments · May be fixed by #1899
Open

Error loading/configuring a C# .net project #1865

Farravid opened this issue Apr 25, 2022 · 4 comments · May be fixed by #1899
Labels

Comments

@Farravid
Copy link

Farravid commented Apr 25, 2022

What seems to be the problem?

Hi everyone! First of all thanks in advance for your help.
I'm trying to set up my C# .net project with premake5 and I'm having the next error:
Current solution contains incorrect configurations mappings. It may causes projects to not work correctly. Open the Configuration Manager to fix them.
image

This happens right after generating the project files when I open the Visual Studio solution.
Which is quite weird is if I press the "Open Configuration Manager" button and close the pop up without changing anything. It works.
Apart from that, the bin and obj directories are not properly configurated. I got a bin/ and obj/ generated inside the project folder.

What did you expect to happen?

A C# .net project working fine. Also the bin and obj directories generated inside the project folder should be in the targetdir and objdir specificated locations

What have you tried so far?

I've tried to write my own Directory.Build.props in order to patch some errors but it doesn't work as expected and as I said it's just a patch. I would like premake5 to do this.

How can we reproduce this?

You can reproduce this by replicating my little test project. Having installed NET core 6.0 and visual studio tools needed to create a net core project.
This is my directory hierarchy:

  • LeafEditor (folder with C# code and project)
    • src (empty folder)
    • premake5.lua (I will call it Project premake)
  • premake5.lua (I will call it Workspace premake)
  • premake5.exe

The code of Workspace premake looks like this:

workspace "LeafEngine"
	startproject "LeafEditor"

	configurations { "Debug", "Release" }
	platforms { "x86", "x86_64" }
	flags { "MultiProcessorCompile" }
	
	outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.platform}"

include "LeafEditor"

The code of Project premake looks like this:

project "LeafEditor"
	kind "WindowedApp"
	language "C#"
 	csversion "10"
	clr "Unsafe"

	targetdir   ("%{wks.location}/bin/" .. outputdir .. "/%{prj.name}")
 	objdir      ("%{wks.location}/bin-obj/" .. outputdir .. "/%{prj.name}")

	dotnetframework "net6.0"

	files
	{
		"src/**.cs",
		"src/**.xaml",
		"src/**.xaml.cs",
	}

	links
	{
		"Microsoft.CodeAnalysis.CSharp.NetAnalyzers",
		"Microsoft.CodeAnalysis.NetAnalyzers",
		"System.Text.Json.SourceGeneration",
		"Microsoft.NETCore.APP",
	}

filter "system:Windows"
 	defines "LF_WINDOWS"
	
 filter "system:Unix"
 	defines "LF_LINUX"

 filter "configurations:Debug"
 	defines "LF_DEBUG"
 	runtime "Debug"
 	symbols "on"
	 
 filter "configurations:Release"
 	defines "LF_RELEASE"
 	runtime "Release"
 	optimize "full"

That is all you need to reproduce the bug.

What version of Premake are you using?

premake5 (Premake Build Script Generator) 5.0.0-beta1
I tried building for Visual Studio 2019 and 2022.

Anything else we should know?

As I said the project builds once I hit the "Open Configuration Manager" but the platform for this build is "Any CPU" and I can't change that.

@Farravid Farravid added the bug label Apr 25, 2022
@Laocoon7
Copy link

Laocoon7 commented May 4, 2022

I ran into the same error, You can boil it down to dotnetframework "net6.0" not playing nice with platforms(). However, dotnetframework "4.8" works fine.

Below is a minimal premake5.lua to replicate the problem. I have a premake5 v5.0.0-dev that works just fine with this file, though this script spits out Error: [string "vstudio/vs2005.lua"]:9: attempt to index a nil value (field 'sln2005') when attempting to run it with the premake5 5.0.0-beta1 off the wiki binaries. I didn't look into that further and is not related to this issue.

workspace "MyWorkspace"
    configurations { "Debug", "Release" }
    platforms "x64"

    project "MyProject"
        kind "ConsoleApp"
        language "C#"
        dotnetframework "net6.0"

EDIT:
It seems to also affect C++/CLI projects targeting .net6.0 not writing to the proper configuration field. I will open a new Issue for that problem.

@Farravid
Copy link
Author

Farravid commented May 5, 2022

Yep, that's the problem, thanks! Hope they can solve it

@nickclark2016
Copy link
Member

Apologies on long turn around time. I'm going to start looking into this today and will hopefully have a fix out soon!

@nickclark2016 nickclark2016 linked a pull request Jun 25, 2022 that will close this issue
6 tasks
@GloriousPtr
Copy link

GloriousPtr commented Apr 12, 2023

Posting here as it seems related: Along with this issue, dlls inside link{} is also not working and will result in build failure.
Turned out it was the issue with platforms tag. The workaround mentioned #1963 works well.

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

Successfully merging a pull request may close this issue.

4 participants