Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformed config in output directory but excluded from _PublishedWebsite folder #152

Open
rpearson-catdevnull opened this issue Jul 7, 2014 · 8 comments
Labels

Comments

@rpearson-catdevnull
Copy link

Hi,

Hopefully someone can help as I've been trying to sort this for hours but I'm at a loss.

We have a web application project which uses SlowCheetah to transform a log4net.cfg for multiple environments.

As part of our setup we have a TFS2013 build server which produces our deployments (running using web publishing pipeline - _WPPCopyWebApplication=True). The build process builds for multiple environments are drops them into a drop folder.

Now I've configured the transforms for the environment builds, and indeed if I publish locally everything is working fine however when using the build server this is what I see:

For each environment in the output folder I can see the correctly transformed log4net.cfg however if I browse into the _PublishedWebsite folder the log4net.cfg there is the base one. I've confirmed it's copying the base (un-transformed one) by setting its Build Action to None and it stops being copied.

So my problem is - the correctly transformed log4net.cfg is copied to the output folder but then not copied into the _PublishedWebsite. Obviously the work around is to manually copy it before deployment but as we're currently in the middle of setting up Continual Deployment this really won't be an option going forward.

I've tried using this tutorial http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/deploying-extra-files to include the log4net.cfg from the output directory into the _PublishedWebsite folder without much success.

If this issue is not a SlowCheetah issue but is likely an MsBuild/WPP problem then let me know and I'll move the question elsewhere. Just somewhat at a loss at the moment!

Cheers,
Richard

@rpearson-catdevnull
Copy link
Author

In case anyone is interested I've resolved this issue by forcing a transform after build. This results in the transformed XML being written into the published websites output folders:

  <Target Name="AfterBuild">
    <TransformXml Condition="Exists('$(OutDir)\_PublishedWebsites\$(TargetName)')" Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="$(OutDir)\_PublishedWebsites\$(TargetName)\Web.config" />
    <TransformXml Condition="Exists('$(OutDir)\_PublishedWebsites\$(TargetName)')" Source="log4net.cfg" Transform="log4net.$(Configuration).cfg" Destination="$(OutDir)\_PublishedWebsites\$(TargetName)\log4net.cfg" />
  </Target>

This was added to the csproj of the website (at the bottom!).

I also had to remove _WPPCopyWebApplication=True from my build configuration - which wasn't actually needed it turns out.

@sayedihashimi
Copy link
Owner

Should we keep this issue open? It sounds like there is a legit bug here. If so could you re-open with steps for me to reproduce this?

@rpearson-catdevnull
Copy link
Author

Hi Sayed,

I'll try and get some time to write up the steps. I'll reopen this as soon as I have something more for you.

Cheers,
Richard

@rpearson-catdevnull
Copy link
Author

Replication Steps:

  1. Create new standard ASP.NET Webforms App (we've also seem the same issue on an MVC App).
  2. Check into TFS 2013
  3. Setup build. Here's some screenshots of the TFS Build settings - we're just using the standard Default Template for TFS 2013 builds:

image
image
image
image
image

Just leave Retention Policy to be the default. So the only real configuration is pointing the build at the website and setting it to build the Release and Debug configurations.

  1. Sanity Check - check the build is working. It is. Here's the log for the standard website build in debug: http://pastebin.com/9gYnYVt5
  2. So now we have a new website let's setup SlowCheetah and a file to transform. Add SlowCheetah NuGet. Version 2.5.10.6.
  3. Add a log4net.cfg file. Here's the contents:
<log4net>
  <!-- Log everything to a rolling log file in XML format -->
  <!-- Create a new rolling log file every day -->
  <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
    <file type="log4net.Util.PatternString" value="..\logging\file-%property{log4net:HostName}.log" />
    <staticLogFileName value="true" />
    <appendToFile value="true" />
    <rollingStyle value="Date" />
    <datePattern value=".yyyy-MM-dd" />
  </appender>
  <root>
    <level value="Info" />
    <appender-ref ref="RollingLogFileAppender" />
  </root>
</log4net>
  1. Now add the Transforms (Right Click->Add Transforms). Here's the contents of the new transform files:

log4net.Debug.log

<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations 
     see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<log4net xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appender>
    <file value="C:\debug.log"
          xdt:Transform="SetAttributes(value)"/>
  </appender>
</log4net>

log4net.Release.log

<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations 
     see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<log4net xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appender>
    <file value="C:\release.log"
          xdt:Transform="SetAttributes(value)"/>
  </appender>
</log4net>
  1. Check it all into TFS
  2. Run that build again
  3. Goto the build output folder and observe the bug.

So in the output folder (...\Drop\Prototypes\SlowCheetahBugReplication\SlowCheetahBugReplication_20140709.2\Debug) I can see a log4net.cfg which has the following content:

<log4net>
  <!-- Log everything to a rolling log file in XML format -->
  <!-- Create a new rolling log file every day -->
  <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
    <file type="log4net.Util.PatternString" value="C:\debug.log" />
    <staticLogFileName value="true" />
    <appendToFile value="true" />
    <rollingStyle value="Date" />
    <datePattern value=".yyyy-MM-dd" />
  </appender>
  <root>
    <level value="Info" />
    <appender-ref ref="RollingLogFileAppender" />
  </root>
</log4net>

However in the published website folder (...\Drop\Prototypes\SlowCheetahBugReplication\SlowCheetahBugReplication_20140709.2\Debug\ _PublishedWebsites\SlowCheetahBugReplication) I see a log4net.cfg with the following content:

<log4net>
  <!-- Log everything to a rolling log file in XML format -->
  <!-- Create a new rolling log file every day -->
  <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
    <file type="log4net.Util.PatternString" value="..\logging\file-%property{log4net:HostName}.log" />
    <staticLogFileName value="true" />
    <appendToFile value="true" />
    <rollingStyle value="Date" />
    <datePattern value=".yyyy-MM-dd" />
  </appender>
  <root>
    <level value="Info" />
    <appender-ref ref="RollingLogFileAppender" />
  </root>
</log4net>

As you can see the transformed log4net.cfg has made it into the output folder but not in the published website folder.

The same is observed for the Release build.

Here's the msbuild log for the debug build: http://pastebin.com/CujybsTJ

Hopefully that helps. I can happily package up this solution (which I've built from scratch to demonstrate the issue) if you'd like it.

Cheers,
Richard

@sayedihashimi
Copy link
Owner

Sorry for the delay here. Thanks for the repro steps. No need for the sample.

OK so this is relating to the _PublishedWebsites folder. I've never tested that scenario.

I think if you publish with a publish profile (i.e. PublishProfile=<name>) then it will work.

Let's keep this issue open. I'll update the title to indicate that this relates to PublishedWebsites folder.

@sayedihashimi sayedihashimi changed the title Transformed config in output directory but excluded from published website Transformed config in output directory but excluded from _PublishedWebsite folder Jul 19, 2014
@ulrikal
Copy link

ulrikal commented Sep 2, 2015

Hello. I have the same problem, and I am using a publish profile. The transformed configs are found in my drop folder, but outside of the _PublishedWebsites.

@z32jxs
Copy link

z32jxs commented Mar 10, 2016

Hi, I'm having the same issue with version 2.5.15 and VS2013.

@shurenok2
Copy link

Hi, I also faced this issue with SlowCheetah 2.5.48 and VS2015.
I have a connectionString.config with transformation files for it. After build the file should be placed in bin.
So when I'm building for a configuration Release in VS, I get transformed connectionString.config in bin. But when I run Publish profile (via VS UI) with the same configuration, I get original connectionString.config in bin folder and transformed connectionString.config in the app root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants