简体   繁体   English

如何更改c#中控制台应用程序生成的exe文件的路径?

[英]How to change the path of exe file generated from console application in c#?

I have a console application and when I run it, an exe file is generated in Bin/Debug folder.我有一个控制台应用程序,当我运行它时,会在 Bin/Debug 文件夹中生成一个 exe 文件。

How can I change the path of exe generated to parent folder where src resides?如何将生成的exe路径更改为src所在的父文件夹?

I created a c# console.Net Framework 4.8 project, there are two ways to achieve your needs.我创建了一个 c# console.Net Framework 4.8 项目,有两种方法可以实现你的需求。

The first way you can directly change the way the exe is generated in the properties, and the second way you can use the post-build method to copy the exe to src.第一种方式可以直接在属性中更改exe的生成方式,第二种方式可以使用post-build方式将exe复制到src中。

The first: Modify in project->properties->build->output, for example, modify to..第一种:在project->properties->build->output中修改,比如修改为..
The Debug folder will be generated to the upper layer. Debug文件夹会生成到上层。

The second: copy only the exe.第二种:只复制exe。

xcopy /y /e "$(TargetPath)" "$(SolutionDir)"

在此处输入图像描述

Click on edit to view macros, or refer to documentation .单击编辑以查看宏,或参考文档

在此处输入图像描述

If you want to use it in .net.如果你想在.net中使用它。

xcopy /y /e "$(Targetdir)*.exe" "$(SolutionDir)"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM