Linked App.config is renamed to MyApp.exe.config but not included in Octopack package

Dear support,

I’m facing an issue while packing a Windows service with Octopack.
The App.config is renamed by msbuild to MyApp.exe.config at compile time, but its not included in the .nupkg.
Instead the App.config is included, important to notice is that the \bin\release folder does only contain the renamed MyApp.exe.config.

To me this looks like an timing issue in OctoPack where the packaging is done too soon.

How can I resolve this?

Kind regards,

Job

Edit: update the subject

Hi Job,

Thanks for letting us know about this issue, it definitely should not be happening.
Could you please send us the full build log so we can determine the issue here and raise a bug.

Thanks!
Vanessa

I’ve included the build log for the Windows service project.

Maybe the issue is in here:
The config file of the windows service is linked from another project called ApplicationLogic

@@@

App.config

@@@

Please take a look at line 49 of the log:
The App.config is copied and renamed correctly.
@@@
Copying file from “…\Company-App.Hosted.Api.Workflow.ApplicationLogic\App.config” to “bin\Debug\Company-App.Hosted.Api.Workflow.exe.config”.
@@@

OctoPack takes the App.config instead of the Company-App.Hosted.Api.Workflow.exe.config:
@@@
OctoPack: Packaging a console or Window Service application
OctoPack: Add binary files
OctoPack: Added file: App.config
OctoPack: Added file: Company-App.Hosted.Api.Workflow.exe
@@@

buildlog.txt (15 KB)

Hi Job,

Thanks for the Info.

This definitely looks like a bug, and I have raised the issue here: https://github.com/OctopusDeploy/Issues/issues/970
You can view and track the issue through that link.

Thanks for reporting this to us!

Vanessa

Hi All,

+1 for this issue. We are seeing it on a ConsoleApp deployment.

App.config gets copied, but MyAppName.exe.Config doesn’t.

The \bin\release definitely contains MyAppName.exe.config and relevant MyAppName.exe.{environment}.config files.

(Added this same comment on GitHub.

Thanks for looking into it.

Hi guys,

We have a related issue using OctoPack attempting to package an Application with one or more environment configurations e.g. ‘App.Staging.config’.

Our goal is to be able to keep our environment configs for Application projects named as ‘App.*.config’ and have them automatically renamed to the correct output config filename during build.

We have a custom build target that copies and renames our ‘environment’ config files to output path as ‘MyApp.exe.*.config’ to suit the special instructions for transforming ‘App’ configs at the bottom of this article: http://docs.octopusdeploy.com/display/OD/Configuration+files

We also set all our ‘environment’ configs to Build Action ‘Content’ to indicate that they’re copied to the output folder when built and (presumably) this would mean they should be included in the OctoPack deployment package that’s created too. At least, this approach works for ‘Web’ projects.

However, for Applications, when we run OctoPack, the transformed ‘MyApp.exe.Staging.config’ files are not included in the package.

The article also notes that we should set the ‘Copy to Output Directory’ property to ensure it’s copied, however this merely copies the originally named ‘App.Staging.config’ to the output folder, which Octopus Deploy won’t transform.

Is there a reason why OctoPack is ignoring our transformed config files? Our transforms are the first targets to run, and everything else in the OutputPath folder seems to get included just fine.

Hi Sebastian,

In old versions of OctoPack we used to just package up everything in the output path. This turned out to cause a lot of problems - some build servers use the same output path for all projects, for example, so we end up packaging a lot of files we aren’t supposed to. Instead, we use a property that MSBuild provides called @(FileWrites), which tells us the files that were output during the project build. I’m not sure how you are renaming your App.*.config files during the build, but if you can change the process so that the written files are appended to @(FileWrites), then OctoPack should pick them up.

Hope that helps!

Paul

Hi Paul,

Thanks! That’s absolutely perfect. In fact, it turns out that appending the files to ‘@(FileWrites)’ is generally good practice anyway.

Thanks for the speedy response!

Hi all, I’m stuck here and wondering if someone could share some more details/code snippet? I can’t seem to figure out how to append the files to the msbuild property.

Hi Larry,

The following CodeProject article explains in good detail how to append files to the FileWrites property.

http://www.codeproject.com/Articles/42853/Strongly-typed-AppSettings-with-MSBuild

The gist of it is that to include files that are generated during the build process but not included by MSBuild can be added by using the following:

<ItemGroup>
  <Compile Include="$(GeneratedFileOrFiles)"></Compile>
  <FileWrites Include="@(GeneratedFileOrFiles)"/>
</ItemGroup>

Hope that helps!

Thank you and warm regards,
Henrik Andersson

Thanks for the quick response Henrik! I got the application configuration transforms to be included now in the nuget package now.

Hi!
I’m now running into the problem where the app transforms aren’t working properly even with the “Automatically run configuration transforms” file checked. The error message seems to indicate that OD is trying to transform a web.config (which isn’t present since it’s a windows service). The config file and appropriate transforms are present (myapp.exe.config and myapp.exe.DEV.config respectively) and seems like I’m doing everything correctly according to these links: http://help.octopusdeploy.com/discussions/problems/10911-appconfig-and-xml-config-transforms-are-not-working and http://help.octopusdeploy.com/discussions/problems/10911-appconfig-and-xml-config-transforms-are-not-working. Am I missing something here?

Thanks in advance,

Larry

Hi Larry,

Could you please send through the raw log file for the deployment task (http://docs.octopusdeploy.com/display/OD/Get+the+raw+output+from+a+task) and I will take a look and see if I can see what may be going wrong here?

If there are sensitive information in the log file, please feel free to email the logs directly to us support at octopusdeploy dot com.

Thanks Henrik

I just submitted a private ticket with raw log.

Thanks,

Larry Asakura
AltSource, Inc.
919-986-0171| larry@altsrc.netmailto:larry@altsrc.net

image001.jpg

Here is the ticket info:
Octopus Deploy tender2+deea3683fe0d5cb3ac7b1bf9abaea374881cefac7@tenderapp.commailto:tender2+deea3683fe0d5cb3ac7b1bf9abaea374881cefac7@tenderapp.com
Re: Linked App.config is renamed to MyApp.exe.config but not included in Octopack package [Problems #21023] [problems #26413]

Thanks,

Larry Asakura
AltSource, Inc.
919-986-0171| larry@altsrc.netmailto:larry@altsrc.net

From: Larry Asakura
Sent: Monday, November 3, 2014 9:34 AM
To: ‘Henrik Andersson’
Subject: RE: Linked App.config is renamed to MyApp.exe.config but not included in Octopack package [Problems #21023]

Thanks Henrik

I just submitted a private ticket with raw log.

Thanks,

Larry Asakura
AltSource, Inc.
919-986-0171| larry@altsrc.netmailto:larry@altsrc.net

image001.jpg

I think this is good to go from my perspective and can be closed if j.vermeulen is good to go. Thank you.