简体   繁体   English

如何在fsc.exe(F#)或csc.exe(C#)中包含app.config文件?

[英]How to include app.config file with fsc.exe (F#) or csc.exe (C#)?

I have a console application that uses an app.config file however I can't figure out how to include that in the command line parameters so that the output will create the Program.exe.config when I compile it programmatically with fsc.exe. 我有一个使用app.config文件的控制台应用程序,但是我无法弄清楚如何在命令行参数中包含该文件,以便当我使用fsc.exe进行程序编译时,输出将创建Program.exe.config。 Right now my workaround is just to rename app.config to Program.exe.config and copy it to the same output location as Program.exe. 现在,我的解决方法是将app.config重命名为Program.exe.config并将其复制到与Program.exe相同的输出位置。 What I need is the fsc.exe command line arguments to do this, however I suspect that csc.exe will have something identical or quite close to what fsc.exe does, so if you know what it is in csc.exe I'll try it out. 我需要的是fsc.exe命令行参数才能执行此操作,但是我怀疑csc.exe具有与fsc.exe相同或非常接近的功能,因此,如果您知道csc.exe中的内容,我会试试看。

Bob 短发

I don't think the F# compiler has any built in support for copying app.config to the output directory. 我认为F#编译器没有内置支持将app.config复制到输出目录。 Simply copying & renaming the file should do the trick - there is nothing more complicated going on. 简单地复制和重命名文件就可以解决问题-没有比这更复杂的事情了。

If you want to get this done automatically, you can add a post-build event like this: 如果要自动完成此操作,则可以添加如下构建后事件:

copy $(ProjectDir)app.config $(TargetDir)$(TargetFileName).config

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

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