开发者

Including app.config in setup output

开发者 https://www.devze.com 2023-01-04 06:51 出处:网络
I have a solution with several projects: MyLibrary (a VB.NET dll) .dll app.config MyService (C# Windows Service with ProjectInstaller)

I have a solution with several projects:

MyLibrary (a VB.NET dll)
  .dll
  app.config
MyService (C# Windows Service with ProjectInstaller)
  .exe
  app.config
MyGui (C# WinForms app)
  .exe

I've added a setup project and added primary outputs of all three projects. I've 开发者_高级运维added all three project outputs to custom action section. The thing is no matter what I do I couldn't get MyLibrary.dll.config to install in application folder. The .config file is in the project\bin\debug folder but not in application folder. What am I doing wrong?


Use Add->Project Output and select Content Files


Only solution I was able to find is manually add the file to the setup project.


Ensure that the ExcludeFilter property on the Primary Output from the project doesn't contain *.config, i think this id turned on by default


Just a note. Even if you add the app.config for your dll, your exe will ignore it by default. In other words, if you are running an exe that uses your dll, the dll's config file won't be loaded. What you probably want to do is add the relevant sections to your exe's app.config. You just add the sections under the configSection tags of your dll's .config file to the configSections of your exe's app.config and then add the userSetting and applicationSettings to your exe's app.config.

Or you can manually load the dll's config in your exe.


Config and other required files will be addes when you have include the primary output in Application Folder.

Once installed the setup, in Installation folder it could be exename.exe and that type was 'Configuration File'.

Still, you are unable to find the config file, Please include it in manually through 'Add File' in Application folder.

Kindly refer the following link.

http://balanagaraj.wordpress.com/2007/05/29/create-exe-or-setup-file-in-net-windows-application/


This is the how for the selected answer:

On the app.config you want included, under Properties for the file set Build Action to Content and Copy to Output Directory to Copy always. On the installer under Specify Application Data->Files included Project.Contents Files. This will get app.config in the output.

However: I was not able to get the MyApplication.exe.config which is created form the app.config file in my installer output. In my project I had to rename app.config to MyApplication.exe.config, and then it worked.

0

精彩评论

暂无评论...
验证码 换一张
取 消