I have a project which is targeting .NET Core 3. This project builds and runs fine in both Debug and Release configurations. Both configurations have a Conditional compilation symbol set in Visual Studio of Glue.
The resulting .csproj has the following:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<DefineConstants>TRACE;GLUE</DefineConstants>
<OutputPath></OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<DefineConstants>TRACE;GLUE</DefineConstants>
</PropertyGroup>
As I mentioned earlier, if I run through Visual Studio, all works fine.
If I publish my app through the command line interface, the resulting app seems to ignore the conditional compilation symbol.
As a test, I added an #if around a section of code which will cause compile errors if the #if is excluded.
#if GLUE
public MainGlueWindow()
{
#endif
mSelf = this;
...
If the GLUE conditional compilation symbol is considered, the code should compile fine, but I do get errors when I perform a dotnet publish. The full command I am using is:
dotnet publish GlueFormsCore.csproj -r win-x86 -c Debug
The error suggests the constructor header is missing:
C:\Users\vchel\Documents\GitHub\FlatRedBall\FRBDK\Glue\Glue\MainGlueWindow.cs(95,19): error CS1519: Invalid token '=' in class, record, struct, or interface member declaration [C:\Users\vchel\Documents\GitHub\FlatRedBall\FRBDK\Glue\Glue\GlueFormsCore_tksugttl_wpftmp.csproj]
I should point out that x86 is the only platform in my csproj.
I don't know if the problem is caused by the absence of specifying x86 as the platform, but if so I don't know how to specify that on the dotnet publish command.
Can anyone tell me why the dotnet publish command is not considering the GLUE conditional compilation symbol?
Update 1
I was able to solve the problem by removing the Platform from the csproj PropertyGroup condition, as shown in the following:
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>TRACE;GLUE</DefineConstants>
<OutputPath></OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DefineConstants>TRACE;GLUE</DefineConstants>
</PropertyGroup>
While this does confirm that the problem is related to the platform, I'm not sure how to specify the platform when building. This is unfortunately not a final solution for me because other projects rely on the platform and I cannot remove that from all configurations.
