c# - Visual Studio WinForm 应用程序应编译并输出到特定目录

标签 c# visual-studio winforms desktop-application

我想在以下目录中编译并输出 Visual Studio 2022/.NET 6.0 WinForm 项目的 exe/dll:

GB3:包含 exe/dll 的根目录

--config:calibration.txt,appsettings.json

--logs:日志文件

--db:sqlite 数据库

config、logs 和 db 是子文件夹。

我右键单击项目->属性->输出->基本输出路径,将GB3设置为基本输出路径。

现在的问题是 Visual Studio 在 GB3 下自动创建 \Debug\net6.0-windows 文件夹,并在 GB3\下输出 exe 和 dll Debug\net6.0-windows 而不是简单地在“GB3”下。如何在“GB3”下输出 exe 和 dll,而不是在 GB3\Debug\net6.0-windows 下输出?非常感谢提前

最佳答案

您还需要使用 OutputPath 而不是 BaseOutputPath,项目文件应如下所示。

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWindowsForms>true</UseWindowsForms>
    <ImplicitUsings>enable</ImplicitUsings>
    <OutputPath>GB3\</OutputPath>
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
  </PropertyGroup>

</Project>

关于c# - Visual Studio WinForm 应用程序应编译并输出到特定目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76549996/

相关文章:

c# - 在 C# 中从单个网络流发送多种类型的数据

c# - 在 C++/CLI/C# 项目中启用 "Native Code Debugging"会使应用程序崩溃

java - IntelliJ IDEA 的 Visual Studio 白色背景主题

c# - 计时器永不停止

C#:按下 Enter 键时更改 DropDownList 值

c# - 何时检查 InnerException

c# - 为什么 IsLiteral 对十进制返回 false?

c# - 当我尝试添加文件时 Visual Studio 卡住

visual-studio - Mindscape Web Workbench 使用 Sass 编译时生成重复的 CSS 文件

c# - 如何删除由 c# 中的 xmlreader 打开的文件?