【发布时间】:2020-03-10 15:57:56
【问题描述】:
我有以下来源(main.cs)
using System;
namespace csexec
{
class Program
{
static void Main(string[] args)
{
int i = 0;
Console.WriteLine("Hello World!");
}
}
}
还有以下CMakeLists.txt
cmake_minimum_required (VERSION 3.14.0)
project(csexec VERSION 0.1.0 LANGUAGES CSharp)
include(CSharpUtilities)
set(PROJECT_SRC
main.cs
)
add_executable(csexec ${PROJECT_SRC})
set_property(TARGET csexec PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.6.1")
set_property(TARGET csexec PROPERTY WIN32_EXECUTABLE TRUE)
set_property(TARGET csexec PROPERTY VS_DOTNET_REFERENCES
"Microsoft.CSharp"
"PresentationCore"
"PresentationFramework"
"System"
"System.Core"
"System.Data"
"System.Data.DataSetExtensions"
"System.Net.Http"
"WindowsBase")
我正在将 CMake 与 Viual Studio 一起使用。这是CMakeSettings.json:
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Visual Studio 16 2019 Win64",
"configurationType": "Debug",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${workspaceRoot}/build/vs2019/build",
"installRoot": "${workspaceRoot}/build/vs2019/install",
"cmakeExecutable": "C:\\Program Files\\CMake\\bin\\cmake.exe",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": [
{
"name": "CMAKE_TOOLCHAIN_FILE",
"value": "H:/Projects/vcpkg/scripts/buildsystems/vcpkg.cmake",
"type": "PATH"
},
{
"name": "VCPKG_TARGET_TRIPLET",
"value": "x64-windows",
"type": "STRING"
}
]
},
{
"name": "x64-Release",
"generator": "Visual Studio 16 2019 Win64",
"configurationType": "Release",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${workspaceRoot}/build/vs2019/build",
"installRoot": "${workspaceRoot}/build/vs2019/install",
"cmakeExecutable": "C:\\Program Files\\CMake\\bin\\cmake.exe",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": [
{
"name": "CMAKE_TOOLCHAIN_FILE",
"value": "H:/Projects/vcpkg/scripts/buildsystems/vcpkg.cmake",
"type": "PATH"
},
{
"name": "VCPKG_TARGET_TRIPLET",
"value": "x64-windows",
"type": "STRING"
}
]
}
]
}
项目在 Visual Studio 中生成和构建没有问题,但是当我从控制台运行它时,Hello World 消息没有出现。如果我通过在该行中放置一个断点从 Visual Studio 运行它,它不会中断。我想我需要指定应用程序的入口点。
我可以做些什么来打印消息并使应用程序完全正常运行?
【问题讨论】:
-
也许,事实上您已经设置了
WIN32_EXECUTABLE,但您已经为 64 位架构设置了其余配置。 -
谢谢,删除该参数解决了问题。如果你回答我会接受。
标签: c# visual-studio cmake