Visual Studio 2017 更改目标构建时 dotnet 崩溃
Visual Studio 2017 dotnet crash when changing target build
目前我正在 Visual Studio 2017 年用 C# 构建应用程序。
我需要将目标构建从 "AnyPC" 更改为 "x86"(以便能够调用一些用 C 编写的非托管 dll)。
但是当我只是在配置管理器(或属性)中更改目标构建时->切换到 x86 platform/target;在这之后我 运行 应用程序,dotnet 崩溃并出现错误:"dotnet has stopped working"。
我想我需要在为 x86 目标编译时以某种方式使用 dotnet-x86,并在为 x64 编译时使用 dotnet(x64),以某种方式添加它们的路径,但我不知道该怎么做。我希望你能帮助我
P.S:我正在 Windows 10 x64,VS-2017 社区,使用 .NET 核心 2.0
我的程序:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Need Help");
Console.ReadKey();
}
}
调试输出:'dotnet.exe'(CoreCLR:默认域):已加载 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App.0.6\System.Private.CoreLib.dll'。跳过加载符号。模块已优化,调试器选项 'Just My Code' 已启用。
程序“[7276] dotnet.exe”已退出,代码为 255 (0xff)。
或禁用 [=30=]:'dotnet.exe' (CoreCLR: DefaultDomain): 已加载 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App.0.6\System.Private.CoreLib.dll'。无法找到或打开 PDB 文件。
程序“[1764] dotnet.exe”已退出,代码为 255 (0xff)。
image of application
谢天谢地,我找到了问题的正确答案:https://github.com/dotnet/cli/issues/7532
.NET Core CLI 团队提到的修复如下:
Install both the x86 and x64 .NET Core 2.0 SDKs from https://www.microsoft.com/net/download/core. Put the following in a file named Directory.Build.targets that is somewhere above your project file (e.g. the root of the source repository). MSBuild will pick it up automatically for all projects:
<Project>
<PropertyGroup
Condition="'$(OS)' == 'Windows_NT' and
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
'$(SelfContained)' != 'true'"
>
<RunCommand Condition="'$(PlatformTarget)' == 'x86'">$(MSBuildProgramFiles32)\dotnet\dotnet</RunCommand>
<RunCommand Condition="'$(PlatformTarget)' == 'x64'">$(ProgramW6432)\dotnet\dotnet</RunCommand>
</PropertyGroup>
</Project>
目前我正在 Visual Studio 2017 年用 C# 构建应用程序。 我需要将目标构建从 "AnyPC" 更改为 "x86"(以便能够调用一些用 C 编写的非托管 dll)。 但是当我只是在配置管理器(或属性)中更改目标构建时->切换到 x86 platform/target;在这之后我 运行 应用程序,dotnet 崩溃并出现错误:"dotnet has stopped working"。
我想我需要在为 x86 目标编译时以某种方式使用 dotnet-x86,并在为 x64 编译时使用 dotnet(x64),以某种方式添加它们的路径,但我不知道该怎么做。我希望你能帮助我
P.S:我正在 Windows 10 x64,VS-2017 社区,使用 .NET 核心 2.0
我的程序:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Need Help");
Console.ReadKey();
}
}
调试输出:'dotnet.exe'(CoreCLR:默认域):已加载 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App.0.6\System.Private.CoreLib.dll'。跳过加载符号。模块已优化,调试器选项 'Just My Code' 已启用。 程序“[7276] dotnet.exe”已退出,代码为 255 (0xff)。
或禁用 [=30=]:'dotnet.exe' (CoreCLR: DefaultDomain): 已加载 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App.0.6\System.Private.CoreLib.dll'。无法找到或打开 PDB 文件。 程序“[1764] dotnet.exe”已退出,代码为 255 (0xff)。
image of application
谢天谢地,我找到了问题的正确答案:https://github.com/dotnet/cli/issues/7532
.NET Core CLI 团队提到的修复如下:
Install both the x86 and x64 .NET Core 2.0 SDKs from https://www.microsoft.com/net/download/core. Put the following in a file named Directory.Build.targets that is somewhere above your project file (e.g. the root of the source repository). MSBuild will pick it up automatically for all projects:
<Project>
<PropertyGroup
Condition="'$(OS)' == 'Windows_NT' and
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
'$(SelfContained)' != 'true'"
>
<RunCommand Condition="'$(PlatformTarget)' == 'x86'">$(MSBuildProgramFiles32)\dotnet\dotnet</RunCommand>
<RunCommand Condition="'$(PlatformTarget)' == 'x64'">$(ProgramW6432)\dotnet\dotnet</RunCommand>
</PropertyGroup>
</Project>