Vic*_*aru 5 c# publish .net-core
我有一个针对 .NET Core 3 的项目。该项目在调试和发布配置中都可以正常构建和运行。两种配置都在 Visual Studio 中设置了条件编译符号Glue
。
生成的 .csproj 具有以下内容:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<DefineConstants>TRACE;GLUE</DefineConstants>
<OutputPath></OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<DefineConstants>TRACE;GLUE</DefineConstants>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
正如我之前提到的,如果我通过 Visual Studio 运行,一切正常。
如果我通过命令行界面发布我的应用程序,生成的应用程序似乎会忽略条件编译符号。
作为测试,我在一段代码周围添加了 #if,如果排除 #if,这将导致编译错误。
#if GLUE
public MainGlueWindow()
{
#endif
mSelf = this;
...
Run Code Online (Sandbox Code Playgroud)
如果考虑 GLUE 条件编译符号,代码应该可以正常编译,但是当我执行dotnet publish
. 我使用的完整命令是:
dotnet publish GlueFormsCore.csproj -r win-x86 -c Debug
该错误表明缺少构造函数标头:
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]
我应该指出,这x86
是我的 csproj 中唯一的平台。
我不知道问题是否是由于未指定 x86 作为平台引起的,但如果是这样,我不知道如何在 dotnetpublish 命令上指定它。
谁能告诉我为什么 dotnetpublish 命令不考虑 GLUE 条件编译符号?
我能够通过从 csproj PropertyGroup 条件中删除平台来解决该问题,如下所示:
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>TRACE;GLUE</DefineConstants>
<OutputPath></OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DefineConstants>TRACE;GLUE</DefineConstants>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
虽然这确实确认问题与平台有关,但我不确定在构建时如何指定平台。不幸的是,这对我来说不是最终的解决方案,因为其他项目依赖于该平台,我无法从所有配置中删除它。
归档时间: |
|
查看次数: |
1720 次 |
最近记录: |