premake-core
premake-core copied to clipboard
Generating C# projects does not set the platform target correctly
What seems to be the problem? Generating a C# project using premake does not specify the "Platform Targets" property for the project when an architecture is specified. This results in projects being still marked as "AnyCPU" regardless of the specified architecture.
What did you expect to happen?
The generated csproj should contain a "Platforms" tag in the condition-less PropertyGroup. For example, if the architecture is x64, it should have the following tag: <Platforms>x64</Platforms>.
What have you tried so far?
Manually inserting the <Platforms>x64</Platforms> tag.
How can we reproduce this? Only tested with VS 2019 so far with the following premake file.
project "SHADE_CSharp"
architecture "x64"
kind "SharedLib"
language "C#"
clr "NetCore"
dotnetframework "net5.0"
targetdir (outputdir)
objdir (interdir)
systemversion "latest"
files
{
"%{prj.location}/src/**.cs",
"%{prj.location}/src/**.tt"
}
flags
{
"MultiProcessorCompile"
}
dependson
{
"SHADE_Engine"
}
warnings 'Extra'
filter "configurations:Debug"
symbols "On"
defines {"_DEBUG"}
filter "configurations:Release"
optimize "On"
defines{"_RELEASE"}
- [ ] Visual Studio 2022 (vs2022)
- [x] Visual Studio 2019 (vs2019)
- [ ] Visual Studio 2017 (vs2017)
- [ ] Visual Studio 2015 (vs2015)
- [ ] Visual Studio 2012 (vs2012)
- [ ] Visual Studio 2010 (vs2010)
- [ ] Visual Studio 2008 (vs2008)
- [ ] Visual Studio 2005 (vs2005)
- [ ] GNU Makefile (gmake)
- [ ] GNU Makefile 2 (gmake2)
- [ ] XCode (xcode)
- [ ] Codelite
- [ ] Other (Please list below)
What version of Premake are you using? 5.0.0-beta2
Anything else we should know? None
Does using x86_64 for the architecture instead of x64 work?
@samsinsane Nope, that doesn't seem to work either
I've had a look into this and it looks like we don't support the platforms/architecture APIs for the new .NET project format. As a workaround, you can inject the element using:
require "vstudio"
local platformsElement(cfg)
_p(2,'<Platforms>x64</Platforms')
end
premake.override(premake.vstudio.cs2005.elements, "projectProperties", function (oldfn, cfg)
return table.join(oldfn(cfg), {
platformsElement,
})
end)
@samsinsane Thanks! I looked into overrides and I got an idea of what you're suggesting here. I've appended it to the bottom of my file but, it is indicating that _p inside platformsElement() seems to be undefined?
The error:
premake5.lua:40: syntax error near 'p'
After looking into it further, I managed to fix it by replacing the local keyword for platformsElement()'s definition with function. I'm not sure if this is the correct way though.
Any idea if it will be implemented? @samsinsane
@Pycorax Sorry about that, looks like I made a typo while typing up the snippet - I think I meant to do local function which limits the function to the current .lua file. Glad you were able to figure out the problem with it and get it working.
@JohnathanRvT It's been awhile since I've looked at this, but I think #1899 fixes this. So, should be "soon".