My issue isn't doing the transformation - in fact I've found several ways to do it and from everything OTHER than the Setup Project perspective they all work. The very first thing I tried was manually entering the exact MSBuild script that the tool generates into the CSPROJ. I also tried a MSBuild task in the Build Workflow - and a Custom Activity that the "TransformXML" MSBuild task (what you have in your snippt below) to do the transform.
All of those methods will end up with the transformed config in the "Binaries" output and the hence the Drop Folder for TFS Build. Unfortunately - none of that matters for what I'm trying to accomplish - which is to have the transformed config in the MSI that's being generated. The issue with Visual Studio Setup Projects is that the MSI is generated using Visual Studio itself (devenv.exe) - NOT MSBuild. It's the only project type that's not MSBuild. (And they won't be in Dev 11). Visual Studio will internally compile the application in memory - separate from the other builds it's already done - using the source tree. So ANY automation in any form - such as what you just described is ignored as it regenerates the files. The app.config verbatim in the source folder ends up in the MSI. My problem is that EVERY method I've tried to "change" the contents of the app.config file fails with a "file in user" error. I don't know WHAT is "locking" app.config and why it's different from any other file in the source tree. I'm beginning to think I have no choice but to "bite the bullet" and learn WIX. The problem is that we don't really have the "budget" for it on the project I'm working on. I know TFS Build very well - so was hoping to get the build automated in the few days I have between projects at my client... From: [email protected] [mailto:[email protected]] On Behalf Of Wes MacDonald Sent: Wednesday, December 28, 2011 12:55 PM To: ozTFS Subject: RE: TFS 2010 Build Issue modifying app.config Hi, You have a few choices, you can use this Visual Studio Add-in: http://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5 or edit the .csproj to include the following lines and insert the following lines immediately before the last </Project> this swaps the contents of the .config after compile. <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" /> <Target Name="AfterCompile" Condition="exists('app.$(Configuration).config')"> <!-- Generate transformed app config in the intermediate directory --> <TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" /> <!-- Force build process to use the transformed configuration file from now on. --> <ItemGroup> <AppConfigWithTargetPath Remove="app.config" /> <AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config"> <TargetPath>$(TargetFileName).config</TargetPath> </AppConfigWithTargetPath> </ItemGroup> </Target> You must have your transforms stored in App.<configuration name>.config like this: [cid:[email protected]] The App.<configuration name>.config must at a minimum contain the following: <?xml version="1.0"?> <!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 --> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> </configuration> Here is an example of our app.lab.config <?xml version="1.0"?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <connectionStrings xdt:Transform="Replace"> <add name="TailspinConnectionString" providerName="System.Data.SqlClient" connectionString="data source=(local);User Id=sqluser;Password=pass@word1;initial catalog=TailspinToys;multipleactiveresultsets=True;" /> </connectionStrings> </configuration> Does that help? Wes Wes MacDonald LIKE 10 INC.<http://www.like10.ca/> 1150 - 45 O'Connor Street Ottawa, ON K1P 1A4 Microsoft MVP: Visual Studio ALM<https://mvp.support.microsoft.com/profile/Wes.MacDonald>, MCTS, MCITP (SharePoint 2010) Blog<http://blogs.like10.com/> | Mobile: +1.613.219.7841 | Office: +1.613.755.4055 | Lync<sip:[email protected]> | Email<mailto:[email protected]> | about.me<http://about.me/wesmacdonald/bio> | Twitter<http://twitter.com/wesmacdonald> "Risk comes from not knowing what you're doing. " -- Warren Buffet From: [email protected]<mailto:[email protected]> [mailto:[email protected]]<mailto:[mailto:[email protected]]> On Behalf Of Daniel Sniderman Sent: December-28-11 1:32 PM To: [email protected]<mailto:[email protected]> Subject: TFS 2010 Build Issue modifying app.config While I know WIX is supposed to be the way to go - I've been hoping I can avoid learning it for now and continue to use the setup process using Visual Studio Setup Projects by the well documented process to run devenv to create the MSI file using the VS Setup Project. This is for a Windows Forms Application. The issue I can't figure out how to get around - some process seems to put a "lock" on the app.config file. I can successfully modify AssemblyInfo.cs all day long - but I'm trying to use the "TransformXML" MSBuild Task (I've tried both MSBuild Task and writing a custom task) I am successful transforming the file - but I need to copy it back over the "app.config" in the source tree - so when devenv.exe invokes to create the MSI file - it has the modified one. But every method of trying to overwrite the "app.config" shows that the file is in use. Any idea what is holding on to that file and why I can't overwrite it? I'm currently using a modified "Default" Xaml Workflow and doing it after the "Get Workspace" task (naturally). Daniel P. Sniderman| Sr Consultant| Magenic MCSD.NET, MCTS: Team Foundation Server 2010 Administration 333 E. Butterfield Rd. Suite 100, Lombard, IL 60148 Mobile: 847-668-4882 | eFax 847-390-7810 magenic.com | [email protected]<mailto:[email protected]>
<<inline: image001.png>>
_______________________________________________ oztfs mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/oztfs
