Geeks With Blogs

News
Employers
Soppa Group India
iSmart Panache Inc
R Systems Internationals Ltd
Technovate eSolutions Pvt Ltd
The contents of this blog are my personal opinion and do not represent in any way the view of my employer.
These postings are provided "AS IS" with no warranties, and confer no rights.

Google PR™ - Post your Page Rank with MyGooglePageRank.com

Narendra Tiwari

Unlike Website we have the notion of having Assemblyinfo.cs file in ClassLibrary projects in Properties folder. Here we need not to use GenerateAssemblyinfo task but we still need to edit the assemblyinfo details like AssemblyVersion, AssemblyKeyFile.

To achieve this we install AssemblyInfoTask it will be installed in ..\Program Files\MSBuild\Microsoft\AssemblyInfoTask\.. folder.
we import the following target file at the end of .csproj file:-

<Import Project="$(MSBuildExtensionsPath)\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets" Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets')" />

All the Assembly attributes are defined in this file which is passed to this target file through MSBuild script file.

Here we need to discuss the Microsoft.VersionNumber.targets file for evaluating some of the Assembly attributes.

  <!-- Properties for controlling key signing through assemblyinfo files -->
  <PropertyGroup>
    <AssemblyIncludeSigningInformation>false</AssemblyIncludeSigningInformation>
    <AssemblyDelaySign>false</AssemblyDelaySign>
    <AssemblyKeyFile></AssemblyKeyFile>
    <AssemblyKeyName></AssemblyKeyName>
  </PropertyGroup>

these 3 properties:-
> AssemblyKeyFile
> AssemblyDelaySign
> AssemblyKeyName

are dependent on AssemblyIncludeSigningInformation property and will take effect only when this property is true.
We must have to make AssemblyDelaySign property either false/true, default is false, it is a boolean type and must be exist in the assemblyinfo.cs file otherwise we will get the error thrown by AssemblyInfoTask.dll

No stub entry for AssemblyDelaySign was found in the AssemblyInfo file.

see the code which generates this error:-
Get this code in AssemblyInfoTask.cs (line no 1311)

            if (this.AssemblyIncludeSigningInformation)
            {
                if (!this.ValidateFileEntry(this.AssemblyDelaySign, assemblyInfo, "AssemblyDelaySign", filename)) return false;
                if (!this.ValidateFileEntry(this.AssemblyKeyFile, assemblyInfo, "AssemblyKeyFile", filename)) return false;
                if (!this.ValidateFileEntry(this.AssemblyKeyName, assemblyInfo, "AssemblyKeyName", filename)) return false;
            }
            return true;
        }

        // This validates a single attribute in the file given the value passed into the task, and the file attribute to look up.
        // The filename is only used for making the error message pretty.
        private bool ValidateFileEntry(string taskAttributeValue, AssemblyInfoWrapper assemblyInfo, string fileAttribute, string filename)
        {
            if ((taskAttributeValue != null) && (assemblyInfo[fileAttribute] == null))
            {
                Log.LogError("Unable to update the {0} for {1}: No stub entry for {0} was found in the AssemblyInfo file.", fileAttribute, filename);
                return false;
            }

            return true;
        }

consider a particular case when AssemblyDelaySign is True or False in target file but there is no entry in Assemblyinfo.cs, you will get the error:-
No stub entry for AssemblyDelaySign was found in the AssemblyInfo file., we need to make sure that ValidateFileEntry function in code block work properly, for this always put some values false/true in attribuets which are of boolean type and that attribute must be exist in Assemblyinfo.cs

see also:
MSBuild AssemblyInfoTask:- Update Assemblyinfo.cs for .csproj
AssemblyInfoTask

Posted on Wednesday, February 15, 2006 12:34 PM .Net | Back to top


Comments on this post: MSBuild AssemblyInfotask: No stub entry Error and resolution

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Narendra Tiwari | Powered by: GeeksWithBlogs.net