开发者

Updating AssemblyVersion in pre-build task causes test failure

开发者 https://www.devze.com 2023-01-29 11:55 出处:网络
We have a simple task that, before compiling, makes all of our AssemblyInfo.cs files editable, then updates

We have a simple task that, before compiling, makes all of our AssemblyInfo.cs files editable, then updates

[assembly: AssemblyVersion("1.0.0.0")]

to

[assembly: AssemblyVersion("1.0.0.<SourceGetVersion>")]

All of our assemblies are signed using the same key.

This kind of thing is probably fairly standard, and it works just fine, except that it causes test failures.

The failures look like this:

Test method Namespace.Tests.MessageTest.TestMethod threw exception: System.IO.FileLoadException: Could not load file or assembly 'Namespace.BusinessLayer.BusinessComponent.Documents, Version=1.0.0.4344, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

So, I turned on the logging that was suggested, and get this:

W, 3964, 90, 2010/12/07, 09:57:43.059, TFSBUILD\QTAgent32.exe, Getting custom attributes for type System.Reflection.RuntimeMethodInfo threw exception (will ignore and use the reflection way): System.IO.FileLoadException: Could not load file or assembly 'Namespace.BusinessLayer.BusinessEntity, Version=1.0.0.4344, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'Namespace.BusinessLayer.BusinessEntity, Version=1.0.0.4344, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx' at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs) at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit) at System.Reflection.RuntimeMethodInfo.GetCustomAttributes(Boolean inherit) at Microsoft.VisualStudio.TestTools.Common.ReflectHelper.GetAttributes(MemberInfo info, Boolean bInherit)

=== Pre-bind state information === LOG: User = domain\tfsbuildAccount LOG: DisplayName = Namespace.BusinessLayer.BusinessEntity, Version=1.0.0.4344, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx (Fully-specified) LOG: Appbase = file:///D:/Builds/4/10/TestResults/tfsbuildAccount-TFSBUILD 2010-12-07 09_56_54_x86_Debug/Out LOG: Initial PrivatePath = NULL Calling assembly : Namespace.BusinessLayer.BusinessComponent.Edi.Tests, Version=1.0.0.4344, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx. === LOG: This bind starts in default load context. LOG: Using application configuration file: D:\B开发者_JAVA技巧uilds\4\10\TestResults\tfsbuildAccount-TFSBUILD 2010-12-07 09_56_54_x86_Debug\Out\Namespace.BusinessLayer.BusinessComponent.Edi.Tests.DLL.config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: Namespace.BusinessLayer.BusinessEntity, Version=1.0.0.4344, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx LOG: Attempting download of new URL file:///D:/Builds/4/10/TestResults/tfsbuildAccount-TFSBUILD 2010-12-07 09_56_54_x86_Debug/Out/Namespace.BusinessLayer.BusinessEntity.DLL. WRN: Comparing the assembly name resulted in the mismatch: Revision Number ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Now, I may have mixed up the assemblies posting this, but it's the same pattern for all the tests. Mind you, the public keys are all the same, and I can see that all of the revision numbers are the same.

What are we doing wrong?


Try changing the reference assebly to be not version specific. "Secific Version = False" in the properties tab for the assembly.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号