【发布时间】:2019-06-29 17:30:14
【问题描述】:
我正在使用带有 C# 8.0 的 Visual Studio 2019,我的项目基于此示例:https://github.com/dotnet/corert/tree/master/samples/HelloWorld
当我打开命令提示符并在我的解决方案文件夹中导航时,我使用以下命令编译本机代码:
dotnet 发布 -c 发布 -r win-x64
这很好用。
但是,在 Visual Studio 2019 中编译/构建(而不是使用 cmd)不会生成本机代码。在输出窗口中没有“生成本机代码”步骤。
这是我的 .csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<AssemblyVersion>1.0.1234</AssemblyVersion>
<TargetFramework>netcoreapp3.0</TargetFramework>
<Platforms>x64</Platforms>
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-*" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>
</Project>
【问题讨论】:
-
我的猜测是目前只有
dotnet publish支持。 -
@IanKemp 以任何方式在 Visual Studio 2019 中执行 dotnet publish?
-
尝试从构建后事件(项目 > 属性 > 构建事件 > 构建后事件命令行)运行它。
-
@IanKemp 这意味着构建项目两次?也许.csproj中有一个条目可以直接用VS2019编译它?
标签: .net-core .net-core-3.0 corert