ExpelaEtege
New Member
From my .csproj file:\[code\]<Content Include="log4net.config"> <SubType>Designer</SubType></Content><Content Include="log4net.Release.config"> <DependentUpon>log4net.config</DependentUpon></Content><Content Include="log4net.Debug.config"> <DependentUpon>log4net.config</DependentUpon></Content><Content Include="log4net.Live.config"> <DependentUpon>log4net.config</DependentUpon> </Content><Content Include="log4net.Demo.config"> <DependentUpon>log4net.config</DependentUpon> </Content> \[/code\]At the bottom of my .csproj file:\[code\] <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> <Target Name="AfterCompile" Condition="exists('log4net.$(Configuration).config')"> <TransformXml Source="log4net.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="log4net.$(Configuration).config" /> <ItemGroup> <AppConfigWithTargetPath Remove="log4net.config"/> <AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config"> <TargetPath>$(TargetFileName).config</TargetPath> </AppConfigWithTargetPath> </ItemGroup> </Target>\[/code\]From log4net.config\[code\]<connectionString name="ConnName" value="http://stackoverflow.com/questions/5557866/Data Source=localhost/sqlexpress;Initial Catalog=localdb;Persist Security Info=True;Integrated Security=SSPI;" />\[/code\]From log4net.Live.config (removed sensitive data)\[code\]<?xml version="1.0" encoding="utf-8"?><configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <connectionString name="ConnName" value="http://stackoverflow.com/questions/5557866/Data Source=127.0.0.1;Initial Catalog=DBName;Persist Security Info=True;User ID=userid;Password=pword" providerName="System.Data.SqlClient" xdt:Transform="Replace" xdt:Locator="Match(name)" /></configuration>\[/code\]I checked msbuild output and I see that it transformed my web.config correctly, but I see no output for it transforming log4net. Also, when I check the log4net.config file after publish, it has the original connection string. What am I doing wrong ?Thanks!UpdateI had some errors in the code that msbuild were outputting as warnings that I didn't see.I fixed those and now I get some output from MSBuild:\[quote\] AfterCompile: Transforming Source File: log4net.config Applying Transform File: log4net.Live.config Output File: obj\Live\Common.UI.Web.dll.config
Transformation succeeded\[/quote\]This is still a problem, because the file should be named log4net.config, not Common.UI.Web.dll.config...For whatever reason \[quote\] $(TargetFileName)\[/quote\]is taking on the name of the .csproj file name. If I replace it with just log4net, then it outputs correctlyUpdateFile is stuck in obj folder and is not getting picked up when publishing.
Transformation succeeded\[/quote\]This is still a problem, because the file should be named log4net.config, not Common.UI.Web.dll.config...For whatever reason \[quote\] $(TargetFileName)\[/quote\]is taking on the name of the .csproj file name. If I replace it with just log4net, then it outputs correctlyUpdateFile is stuck in obj folder and is not getting picked up when publishing.