System.Configuration.dll and MSBee

Topics: For MSBee Users
Aug 16, 2006 at 10:59 PM
migrated from power toy forums
originally posted by IChris
------------------------------------------------------

I am trying to build a project that references System.Configuration.dll

Since 1.1 doesn't have a System.Configuration.dll the code uses "#if FX1_1 ..." with the old System.Configuration classes.

However the project itself still references System.Configuration.dll and so MSBee (MSbuild) outputs a lot of warnings, starting with:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.configuration". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

How can I exclude the reference for 1.1 builds?

Thanks!
I love bees :-)
Aug 16, 2006 at 10:59 PM
originally posted by Craig Lichtenstein - MSFT
------------------------------------------------------

One approach is to conditionalize the System.configuration reference in your project files. This can be done using ItemGroup elements with conditionals.

For example:

<ItemGroup Condition=" '$(TargetFX1_1)' != 'true' ">

<Reference Include="System.Configuration" />

</ItemGroup>

<ItemGroup>

...your standard references...

</ItemGroup>

Thus, when TargetFX1_1 is set to true, MSBuild won't attempt to resolve System.Configuration.
Aug 16, 2006 at 10:59 PM
originally posted by IChris
------------------------------------------------------

I didn't realize that I'm allowed to modify Visual Studio project files in such a way.

A quick test showed that everything works as expected but can I be sure that VS will not mess with my changes?

Other than unloading/edit .csproj - is there a way to show the conditions inside VS?

Thanks!
Aug 16, 2006 at 11:00 PM
originally posted by Bertan Aygun - MSFT
------------------------------------------------------

Visual Studio should not change your modifications to the project file, unless you remove the reference to System.Configuration within Visual Studio.

Also it looks like the only way to edit project files is to unload the project, and choose Edit from context menu.