Visual Studio WinForm应用程序应该编译并输出到特定目录。

huangapple go评论77阅读模式
英文:

Visual Studio WinForm application should compile and output to specific directory

问题

I want to compile and output exe/dlls for Visual Studio 2022/.NET 6.0 WinForm project in the following directory:

GB3: root dir containing exe/dlls

--config: calibration.txt, appsettings.json

--logs: log files

--db: sqlite db

config, logs and db are sub-folders.

I have right-clicked on Project->Properties->Output->Base output path to set GB3 as Base output path.

Now the problem is that Visual Studio is automatically creating \Debug\net6.0-windows folder under GB3, and outputs exe and dlls under GB3\Debug\net6.0-windows instead of simply under 'GB3'. How can I output exe and dlls under 'GB3' and not GB3\Debug\net6.0-windows? Many thanks in advance

英文:

I want to compile and output exe/dlls for Visual Studio 2022/.NET 6.0 WinForm project in the following directory:

GB3: root dir containing exe/dlls

--config: calibration.txt, appsettings.json

--logs: log files

--db: sqlite db

config, logs and db are sub-folders.

I have right-clicked on Project->Properties->Output->Base output path to set GB3 as Base output path.

Now the problem is that Visual Studio is automatically creating \Debug\net6.0-windows folder under GB3, and outputs exe and dlls under GB3\Debug\net6.0-windows instead of simply under ''GB3''. How can I output exe and dlls under ''GB3'' and not GB3\Debug\net6.0-windows? Many thanks in advance

答案1

得分: 2

<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>
英文:

You also need to use OutputPath instead of BaseOutputPath, the project file should look like the following.

<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>

huangapple
  • 本文由 发表于 2023年6月25日 18:41:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76549996.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定