c# - Visual Studio 2017,构建解决方案或发布不生成 .EXE
问题描述
我开发了一个C# 控制台应用程序,它可以在 Visual Studio 环境中正常工作。当我选择“发布”下的“构建解决方案”(但也在“调试”下)时,会生成 .DLL,而不是 .EXE。我可以使用命令行生成 .EXE(“c:\Windows\Microsoft.NET\Framework64\v3.5\csc.exe”后跟 .cs 文件的路径),但应该可以从 Visual Studio 环境中生成 .EXE。
我已将 Visual Studio 配置为使用“C:\c#projs”作为我的项目位置(菜单路径“工具”->“选项”->“项目和解决方案”->“项目位置”而不是 c 下的默认路径:\Users\\Documents....
这是项目文件“App01.csproj”
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputPath>bin\</OutputPath>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<TargetFramework>netcoreapp2.1</TargetFramework>
<StartupObject>App01.SetDirDatesProgram</StartupObject>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>bin\</OutputPath>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<PlatformTarget>x64</PlatformTarget>
<WarningLevel>0</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutputPath>bin\</OutputPath>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<PlatformTarget>x64</PlatformTarget>
<WarningLevel>0</WarningLevel>
</PropertyGroup>
</Project>
这是生成的“App01.deps.json”文件:
"runtimeTarget": {
"name": ".NETCoreApp,Version=v2.1",
"signature": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v2.1": {
"App01/1.0.0": {
"runtime": {
"App01.dll": {}
}
}
}
},
"libraries": {
"App01/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
“App01.deps.json”文件由 Visual Studio 创建,包含(在“ runtime ”键下)“ App01.dll ”而不是“ App01.exe ”。
我的问题是:我需要在 Visual Studio 中修改什么才能获得(在“运行时”键下)“App01.exe”而不是“App01.dll”,显然是为了让 Visual 生成 App01.exe Studio,以便我可以在其他地方部署 App01.exe?
解决方案
在解决方案资源管理器中右键单击项目名称,选择Properties...
然后转到该Application
部分并查找Output type:
确保它设置为Console Application
。
对于 .NET Core 控制台应用程序,我想你会在这个 SO 问题中找到你想要的信息: Build .NET Core console application to output an EXE?
推荐阅读
- ruby-on-rails - Rails Active Storage 将微小图像渲染为 base64
- cluster-computing - 我应该为 hclust 使用 vegdist 还是 dist?
- apache-beam - Beam pipeline - 连续固定时间窗口聚合的差异
- html - 如何使用属性转换 XML?
- c# - .Net Core Visual Studio 项目命令行构建与右键构建相同
- arrays - 如何用 VBA Excel 实现数组?
- php - Eloquent 模型只是显示“价值”而不是插入
- c# - 将数据表中的标题行替换为另一个数据表中的标题行
- python - RoborFramework:如何将标签名称发送到我的关键字中
- javascript - Javascript 不适用于 Firebase 身份验证