Brussells Development Blog

VStudio Web.config Transformation for your App.configs

by on Jul.01, 2011, under Development, Tips and Tricks

I searched high and low for this tid-bit before finally stumbling upon this great question\answer over at Stack Overflow. I’m going to lay out the steps here for reference but credit goes to Oleg Sych and Dan Abramov.

Original article:
App.Config Transformation for projects which are not Web Projects in Visual Studio 2010?

 

1.) Add an XML file for each configuration to the project.

Let’s say your project build settings are Debug.Local, Debug.Production, Release.Local, Release.Production. Then your new app.config files should be titled as app.<build title>.config …. or app.Debug.Local.config, app.Debug.Production.config, etc. One file for each build configuration. Once they are added to your project continue to step 2.

 

2.) Unload project and open *.csproj file for editing

Right-click on the project and select Edit project file from the Solution Explorer.

 

3.) Bind app.configs created in Step 1 to original app.config

Find the section inside the project file that contains app.config and all the app.<build title>.config files you just manually added. Notice how their build actions are set to None.

  1. Set all the app config files build action to Content
  2. Make all the app config files you manually added dependent upon the original app.config file.

When you finished it should look something like this:

<Content Include="App.config" />
<Content Include="App.Debug.config" >
  <DependentUpon>App.config</DependentUpon>
</Content>
<Content Include="App.Release.config" >
  <DependentUpon>App.config</DependentUpon>
</Content>

 

4.) Activate transformation magic

In the end of the file after

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

and before final

</Project>

Insert the following XML:

<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\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>

Now you can reload the project. Make sure that all the manual app.<build settings>.config files you added earlier are now neatly tucked away under the original app.config file.

Build and enjoy!

 

Leave a Comment :, , , , more...


Android SDK Manager Fails to Launch

by on Dec.23, 2010, under Development, Tips and Tricks

Recently I ran into a unique problem that aggrevated me to no end.  I downloaded the latest Android SDK and installed following the exact instructions on Google’s SDK site.  I had all the pre-requisits installed and I was ready to launch the SDK Manager to begin grabbing my package components when I ran into the problem.  Everytime I tried to launch the SDK Manager all I got was a quick flash of a Windows command prompt, then nothing.  This occurred over and over, whether running from the shortcut link inside the Start Menu, or running directly from the command prompt.  Nothing …

After some internet searches, I quickly realised I found similar problems posted on various forums, yet no absolute fix was ever posted.  Long story short, I found the solution to my paticular problem so I shall outline it here for others out there that may run into the same problem.

Problem:
I actually had previous versions of Java JDE installed already on my machine that I forgot about from other development enviroments and IDEs.  Running a simple “java -version” command from the command prompt showed the active JDE was v1.3.  I had installed Java JDK v1.6 Update 23 and installed previously before installing the Android SDK so I knew something was wrong.

Solution:
You can have multiple PATH locations for your JDE \ JDK’s on your system, but what counts is what is first in the list that gets first pick.  So in order to make sure your latest JDK version that Android SDK is requiring is actually first in the system PATH list, follow these steps under Windows 7:

  • Right-click on My Computer -> Properties
  • Click Advanced Settings on the left side of the screen
  • Look at the bottom list called “System variables” and find the entry labeled “Path”
  • Select “Path” from the list and click the Edit button
  • If you haven’t already added the path to your Java JDK’s bin folder, then do so now at the Beginning of the list
  • Otherwise, locate your previous Java JDK bin folder you inserted earlier and make sure it is at the front of the list

Example:
C:\Program Files\Java\jdk1.6.0_23\bin;

Make sure you add the “;” semicolon to the end of the path when you insert it at the beginning of the string.  Click Ok button(s) all the way out of the dialogs and reboot your PC.  Upon rebooting, I ran the “java -version” command again from my command prompt and it correctly displayed my new install of Java JDK v1.6 Update 23.  Android SDK Manager launched too and works great.

I hope this helps you if you run into this problem.

Enjoy!

10 Comments :, , more...


Windows 7 and TortoiseSVN: Can’t move … The file or directory is corrupted and unreadable.

by on Feb.12, 2010, under Development, Tips and Tricks

I recently upgraded to Windows 7 64-bit OS from a Vista OS. I’m loving every minute of it at the moment. One problem I have ran into that appears to be happening with others is the fact TortoiseSVN will puke randomly on updates from a SVN grab. You can see it especially on large SVN checkouts. I have read numerous posts on the matter and I am posting what actually worked for me.

First I make sure any folder that I’m using for a SVN checkout is not flagged for Windows Search Indexing. You can get to this property by right-clicking on the parent folder and select Properties -> Advanced -> Uncheck index for faster searches.

The next item to make sure of is adding the following apps to your Trusted & Exclusion rules inside your Anti-virus \ Protection program of choice.

  • SearchFilterHost.exe  (C:\Windows\System32)
  • SearchProtocolHost.exe  (C:\Windows\System32)
  • TSVNCache.exe  (<TortoiseSVN_dir>\bin)
  • TortoiseProc.exe  (<TortoiseSVN_dir>\bin)

For me, I use Kaspersky 2010. So I had to go into Settings -> Threats … then add TSVNCache and TortoiseProc to their own Exclusion rules telling it to not use <any> on each. I then went to the Trusted Apps tab on the same window and added SearchFilterHost and SearchProtocolHost both as TrustedApps and not take any action on either one. Your protection\anti-virus app may be different of course but the main concept here is to tell it don’t do anything if either 2 of those Tortoise apps are running. The same applies to the Windows Search Indexer, b\c I found that even though you tell the directory DO NOT INDEX, as we did in the first step, there is still things going on in the background which will still negate this whole processs if you just add the 2 Tortoise apps to your Trusted + Exclussion zone in your Anti-virus \ Protection app.

I tried not adding the 2 Windows Search Indexer apps to my Trusted \ Exclussion zones and the problem would only rarely occur, but it STILL occurred. It was only after adding those 2 with the Tortoise apps that the problem ceased to occur any more.

I hope this helps your situation, I enjoy Windows 7 and I can’t live without TortoiseSVN for my work.

-Brandon

3 Comments :, , more...


Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...