Build a build process independent of the GAC

How can we make our build process (Dev Studio 2005) for a .NET project completely independent of what is installed on the GAC on the particular machine on which it runs.

Here's the problem we're trying to solve: depending on which assemblies were installed in the GAC, our build process generates various .NET assemblies in the output directory, which we then use to create the .MSI

Presumably, this is because dev studio assumes that since it is installed in the GAC, it should not be installed as part of our product.

We want to disable this behavior so that all .NET assemblies that directly or indirectly reference our project are copied to the project's output directory (except for standard .NET 2.0 assemblies).

For references to direct assembly, I know that setting "Copy local = true" does the job.

However, this does not work for indirect assembly references.

i.e. One of our projects refers to an assembly called "A.dll", which depends on another assembly called "B.dll", which is located in the same directory as "A.dll". On machines in which "B.dll" is not installed in the GAC, the A.dll and B.dll files are copied to the output directory during the Dev studio build process. This is what we want.

But on machines where B.dll is installed in the GAC, even if "Copy Local = True" for A.dll, B.dll is not copied to the output directory.

+4
source share
3 answers

Like Mark, the only way to do this is to add dependent links and set CopyLocal = True.

But I agree with Danny's answer - do not use Dev Studio for your deployment, because you cannot get enough control over the build process.

Why? There is some “default” logic with Dev Studio, in which, if it calculated the value of the property, then it will not save it in the .CSPROJ file, leaving the Dev Studio instance on the other computer with the default task “ownership of something else!”

The only sure-fire way to do this is to explicitly modify the .csproj xml file directly and make sure you add True to the Reference element:

<ItemGroup> <Reference Include="ConfigManagerClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=20fc1ffb797ec904, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\thirdparty\CM\ConfigManagerClient.dll</HintPath> <!-- If DevStudio inferred this to be true, then it won't explicitly save it. When the project is loaded on another machine on which the assembly is installed in the GAC, Dev Studio on _that_ machine will infer that CopyLocal should be False!! --> <Private>True</Private> </Reference> 

This behavior seems to make it almost impossible to know what your .CSPROJ file will do when it starts on another machine.

In the long run, it is much better for you not to trust the Dev Studio build and packaging process and instead use, say, Nant and explicit command lines.

+4
source

I think you probably should not rely on the Visual Studio build process to do this automatically for you, especially when the results may vary depending on the building machine.

What would I do in this case (this applies to what you are building with Visual Studio or using an automatic build script), you need to have some post-build script (I usually use batch files for simplicity) from the collections your the project in the appropriate directory immediately after the assembly (usually I save any assemblies that are not part of my project in the directory in my source control, so that is all in one place). Then, when you create your installer, everything will be exactly where it should be.

+1
source

The simplest answer should be explicit: add a link to B.dll and install it the way you want.

0
source

All Articles