Using app.config in the July 2009 CTP
In the July 2009 CTP of the Windows Azure Tools for Microsoft Visual Studio, we introduced a bug where if you use the App.Config file in a Worker Role, it won’t get included in your Service Package both when running on the local Development Fabric or in the Cloud.
To resolve this issue, simply add the following environment variable before starting Visual Studio:
AddAppConfigToBuildOutputs=true
This will be fixed in our next release, in fact it’s fixed in our daily builds already.
What happened?
In order to support TFS Build, we changed how files are copied to the package for the Worker Role. As part of the changes, we missed calling one of the targets with a property set to handle the App Config.
It was lucky for us that our customers can workaround the issue by setting the environment variable above and MSBuild will do the right thing.
Scenario
To elaborate on the scenario, if you create a new Cloud Service with a Worker role by clicking File | New Project | Visual C# | Cloud Service and adding a Worker Role:
Right Click on the WorkerRole1 project in Solution Explorer and select Add | New Item and select the “Application Configuration File” item.
Build the solution and navigate to the Service Package (more info on Service Packages) and you’ll find that the app.config file is missing from the worker role. (no WorkerRole1.dll.config)
This is true in the packaging for the Development Fabric and if you Published for the Cloud.
Exit Visual Studio and add the environment variable: AddAppConfigToBuildOutputs=true
Then restart Visual Studio and open up that same solution you were working on.
Rebuild All and again navigate to the Service Package. This time you will see the WorkerRole1.dll.config file as you would expect.
Sorry for the inconvenience, again this is temporary and you now know the workaround.
Some forum threads about this:
- https://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/cc11be6e-097a-499c-96c7-5089d01e2e08
- https://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/7f39b1bd-98ad-4bdd-958d-8f29748a3ee5/
- https://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/604384f0-9d20-4be6-a02c-24ba1ff1bf82
- https://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/20602cec-efa5-4058-ac6a-41bb9e344c17