I'm using .NET 2.0 to develop my product. I've built a build system using
MSBuild that is building my C# assemblies. I've created a strong name key
pair, and I've extracted the public key into a separate file. The MSBuild
build process is using the standard Microsoft.CSharp.targets file to build
my assemblies. I've also configured my MSBuild build process to delay sign
my assemblies using the extracted public key.
Here's the problem that I'm seeing.
My build process is producing 4 assemblies. Three of the assemblies are
based on C# code that I have written. The fourth assembly is an
XmlSerializers assembly that is being generated by the sgen.exe utility.
In the output directory where my assemblies are being written to, only two
of my assemblies and the XmlSerializers assembly appear to have been delay
signed. According to the sn.exe utility, the last assembly isn't delay
signed.
However, looking at the MSBuild log, the csc.exe tool is being run with both
the key file and the delay sign flag. When I look in the intermediate obj
file where the compiler writes the assembly to, the generated assembly is
delay signed.
So when the assembly is being copied by MSBuild into the output directory,
somehow, something is thinking that this assembly is not delay signed. I am
seeing the same behavior for both of my debug and release builds.
Has anyone seen anything similar to this? Any ideas on what I can do to
correct the problem?
Thanks.
Michael
Nicole Calinoiu - 01 Jan 2006 13:52 GMT
Are you sure that the source for the final copy to the output directory is
the assembly that that was compiled with delay signing enabled? If so, what
happens if you attempt to use full signing (e.g.: with a test key rather
than your real key) instead of delay signing?
> I'm using .NET 2.0 to develop my product. I've built a build system using
> MSBuild that is building my C# assemblies. I've created a strong name key
[quoted text clipped - 29 lines]
>
> Michael
msnews.microsoft.com - 01 Jan 2006 16:00 GMT
Yes. According to the MSBuild output, the final copy is being made from the
obj directory where the assembly appears to be signed.
When I run the build script without delay signing, the same problem is still
reproduced. In the intermediate obj directory, the compiler-produced
assembly is signed using the strong name key. It's copy into my bin
directory is still being reported by sn.exe as not strong named.
> Are you sure that the source for the final copy to the output directory is
> the assembly that that was compiled with delay signing enabled? If so,
[quoted text clipped - 35 lines]
>>
>> Michael
msnews.microsoft.com - 01 Jan 2006 16:09 GMT
I reran my build script using the "msbuild /v:diag" option to produce a
detailed build log. I checked the copy command to make sure that it was
copying the assembly from the correct obj directory and it is. When I
copied the complete copy command that the MSBuild script used and ran the
command from the command prompt to recopy my assembly from the obj to the
bin directory, it appears to work. The assembly is now being reported by
sn.exe to be delay signed or fully signed, depending on the build mode. But
when the copy is being made by my MSBuild build script, the assembly is
being reported as not signed.
> Yes. According to the MSBuild output, the final copy is being made from
> the obj directory where the assembly appears to be signed.
[quoted text clipped - 44 lines]
>>>
>>> Michael
Nicole Calinoiu - 01 Jan 2006 16:43 GMT
That's more than a little odd... Have you tried comparing the contents of
the intermediate directory and output directory copies of the assembly file?
If so, do they differ and, if so, how?
>I reran my build script using the "msbuild /v:diag" option to produce a
>detailed build log. I checked the copy command to make sure that it was
[quoted text clipped - 56 lines]
>>>>
>>>> Michael
Michael Collins - 02 Jan 2006 05:16 GMT
Thanks. I figured out my problem. Inside of my solution, I had defined a
project reference from my unit test project to my assembly. When my MSBuild
build script ran the .csproj file for the unit test assembly, the project
reference was recompiling the assembly without the strong name and
overwriting the assembly in the final output directory with the strong name.
> I'm using .NET 2.0 to develop my product. I've built a build system using
> MSBuild that is building my C# assemblies. I've created a strong name key
[quoted text clipped - 29 lines]
>
> Michael