Nightly builds will not complete help file task - SHFB error

Topics: Developer Forum
May 23, 2013 at 8:50 AM
Sandcastle HFB is working well for us on local machines, but I am trying to add it as a task to our TFS CI build server.

We have two builds defined, a CI build and a nightly build. The difference is that the help files are only built overnight. Otherwise the TFSBuild.proj definition is the same (it is actually shared with a conditional help file task)

The nightly build always partially succeeds with a single failure - the help file task fails thus:

C:\Program Files (x86)\EWSoftware\Sandcastle Help File Builder\SandcastleHelpFileBuilder.targets(38,5): error MSB4062: The "SandcastleBuilder.Utils.MSBuild.BuildHelp" task could not be loaded from the assembly C:\Program Files (x86)\EWSoftware\Sandcastle Help File Builder\SandcastleBuilder.Utils.dll. Could not load file or assembly 'file:///C:\Program Files (x86)\EWSoftware\Sandcastle Help File Builder\SandcastleBuilder.Utils.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. Confirm that the <UsingTask> declaration is correct, and that the assembly and all its dependencies are available.

Can anyone guide me on how to resolve this? AFAIK we have only installed one version of SHFB on the build server, so this is a mystery.

Platform: Windows 7 x64, Team System 2008, SHFB 1.9.7.0

On my own dev machine, the same platform, I don't have this issue.
Coordinator
May 23, 2013 at 4:18 PM
From the error it would appear that an older version of MSBuild is being used to build the project. SHFB and its build tasks are compiled with .NET 4.0 and must use MSBuild 4.0. Any earlier version of MSBuild will likely fail with the error above since they only work with the earlier framework versions against which they were built. Also, ensure that the ToolsVersion attribute in the SHFB project file is set to "4.0". This should happen automatically if opened in Visual Studio and when you open and save the project in the standalone GUI.

Eric
May 23, 2013 at 5:34 PM

Eric,

We are using VS2008 Team System on a Windows 7 x64 build server. Does this mean we have a version problem with MSBuild and SHFB? I don’t have any issues on my own dev machine which is the same platform, so I am puzzled.

Also, how do I set the ToolsVersion attribute? I can’t seem to find that anywhere in the SHFB project. I have opened and saved it in the SHFB GUI using Windows 7 x86, but I cannot confirm that it has the correct value. The VS Solution/projects are all configured to use .Net3.5

Regards,

Neil Haughton

Coordinator
May 23, 2013 at 8:13 PM
Assuming VS 2008 Team system corresponds to the same Visual Studio 2008 release, it is most likely using MSBuild 3.5. The standalone GUI runs under .NET 4.0 and controls the build process so it runs MSBuild 4.0 explicitly. Since you've opened and save the project in the standalone GUI, the ToolsVersion attribute should be correct. It's on the root Project element and you'd need to open the project file in a text editor to see it.

As for the build server, one way to get it working would perhaps be to install .NET 4.0 and then use the Exec MSBuild task to run MSBuild 4.0 to build the SHFB project.

Eric
May 24, 2013 at 9:32 AM

Eric,

Thank you for replying.

Our SHFB project has the following opening line:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">

which looks satisfactory. Windows 7 comes with .Net 4 by default (and I have checked it is installed on both machines in question – version 4.04.0319 32 & 64bit), but we only have this problem building the help file on one of the machines (the build server). Both machines have MSBuild 3.5 and 4.0 installed, so your suggestion looks to be in the right direction.

But can you please elaborate what you mean by “use the Exec MSBuild task to run MSBuild 4.0 to build the SHFB project”? Do you mean our TFSBuild.proj file should have something added to the GenerateDocumentation target for force SHFB to use MSBuild 4.0? If so, can you suggest how this might be done? It is commercially important that the application build continues to target .Net 3.5 so it must only be the help file generation that uses MSBuild 4.

FYI I have reproduced our GenerateDocumentation target below:

<Target Name="GenerateDocumentation">

<!-- Build Help docs -->

<!-- Get the UTC time in the specified format -->

<MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="Get" Format="ddMMMyyyy-HH:mm" UseUtc="true">

<Output TaskParameter="Result" PropertyName="DocBuildTime"/>

</MSBuild.ExtensionPack.Framework.DateAndTime>

<PropertyGroup>

<ProjectRelative>projects\Matrix5\Matrix5</ProjectRelative>

<HelpProjectFilePath>$(SolutionRoot)\$(BuildDefinition)\$(ProjectRelative)\Matrix5.shfbproj</HelpProjectFilePath>

<HelpConfig>Configuration=Release;Platform=x86;OutDir=$(OutDir); OutputPath=$(OutDir); HtmlHelpName=Matrix_5_API_Programmers_Guide_$(DocBuildTime)</HelpConfig>

</PropertyGroup>

<Message Text="SolutionRoot is: $(SolutionRoot)"/>

<Message Text="BuildDefinition is: $(BuildDefinition)"/>

<Message Text="Documentation project file is: $(HelpProjectFilePath)"/>

<Message Text="Documentation project config is: $(HelpConfig)"/>

<Message Text="Documentation OutDir is: $(OutDir)"/>

<Message Text="Binaries root is: $(BinariesRoot)"/>

<Message Text="Document build time: $(DocBuildTime)"/>

<MSBuild Condition="'$(BuildDefinition)'!='CI'" Projects="$(HelpProjectFilePath)" Properties="$(HelpConfig)" />

</Target>

Best Regards,

Neil Haughton BSc MIET IEng(CEI)

Development Manager

IncorporatedEngineerC_smaller


Autoscribe Limited
Wellington House,
Riseley Business Park
Basingstoke Road, Riseley
Berkshire RG7 1NW
Office: +44 (0) 118 984 0610
Fax: +44 (0) 118 984 0611
Email: [email removed] Visit our website at: www.autoscribe.co.uk
Registered in Wales No. 1539748


Description: Description: follow_bird_us-a

Description: Description: Description: http://press.linkedin.com/images/LinkedIn_WebLogo_LowResExample.jpg
**********************************************************DISCLAIMER*****************************************************

The contents of this email are confidential and are intended solely for the use of the individual or company to
whom it is addressed. If you have received this email in error then please accept our apology. If this is the case
we would be obliged if you would contact the sender and then delete this email. Opinions expressed in this email
are those of the individual and do not necessarily represent the opinions of Autoscribe Ltd. Although this email
and any attachments are believed to be free of any virus no responsibility is accepted by Autoscribe Ltd for any
loss or damage arising in any way from the receipt or use of this email or attachments.

Coordinator
May 24, 2013 at 8:35 PM
I don't have access to or use Team System so I'm not the best person to ask. My guess is that you'd replace the MSBuild task seen towards the end with a call to the Exec task instead passing it the path to the .NET 3.5 MSBuild and the SHFB project file and any command line property override parameters. See the task documentation for details. It'll probably end up looking something like this:
<Exec Condition="'$(BuildDefinition)' != 'CI'"
        Command="$(PathToMSBuild35) $(HelpProjectFilePath) /p:$(HelpConfig)" />
Eric
May 28, 2013 at 3:03 PM

Eric,

I assume that you mean that in the GenerateDocumentation target override I should first define a property “PathToMSBuild35” which contains the path to the desired MSBuild executable, and that this should actually be the .Net 4 version for SHFB to use?

Best Regards,

Neil Haughton BSc MIET IEng(CEI)

Development Manager

IncorporatedEngineerC_smaller


Autoscribe Limited
Wellington House,
Riseley Business Park
Basingstoke Road, Riseley
Berkshire RG7 1NW
Office: +44 (0) 118 984 0610
Fax: +44 (0) 118 984 0611
Email: [email removed] Visit our website at: www.autoscribe.co.uk
Registered in Wales No. 1539748


Description: Description: follow_bird_us-a

Description: Description: Description: http://press.linkedin.com/images/LinkedIn_WebLogo_LowResExample.jpg
**********************************************************DISCLAIMER*****************************************************

The contents of this email are confidential and are intended solely for the use of the individual or company to
whom it is addressed. If you have received this email in error then please accept our apology. If this is the case
we would be obliged if you would contact the sender and then delete this email. Opinions expressed in this email
are those of the individual and do not necessarily represent the opinions of Autoscribe Ltd. Although this email
and any attachments are believed to be free of any virus no responsibility is accepted by Autoscribe Ltd for any
loss or damage arising in any way from the receipt or use of this email or attachments.

Coordinator
May 28, 2013 at 4:09 PM
Sorry, yes, that should be the path to MSBuild 4.0.

Eric
May 28, 2013 at 4:37 PM

Thanks for all your help.

Best Regards,

Neil Haughton BSc MIET IEng(CEI)

Development Manager

IncorporatedEngineerC_smaller


Autoscribe Limited
Wellington House,
Riseley Business Park
Basingstoke Road, Riseley
Berkshire RG7 1NW
Office: +44 (0) 118 984 0610
Fax: +44 (0) 118 984 0611
Email: [email removed] Visit our website at: www.autoscribe.co.uk
Registered in Wales No. 1539748


Description: Description: follow_bird_us-a

Description: Description: Description: http://press.linkedin.com/images/LinkedIn_WebLogo_LowResExample.jpg
**********************************************************DISCLAIMER*****************************************************

The contents of this email are confidential and are intended solely for the use of the individual or company to
whom it is addressed. If you have received this email in error then please accept our apology. If this is the case
we would be obliged if you would contact the sender and then delete this email. Opinions expressed in this email
are those of the individual and do not necessarily represent the opinions of Autoscribe Ltd. Although this email
and any attachments are believed to be free of any virus no responsibility is accepted by Autoscribe Ltd for any
loss or damage arising in any way from the receipt or use of this email or attachments.

May 28, 2013 at 5:15 PM

Eric,

Finally got it to build successfully, using your suggestions. Thanks for the pointers!

Best Regards,

Neil Haughton BSc MIET IEng(CEI)

Development Manager

IncorporatedEngineerC_smaller


Autoscribe Limited
Wellington House,
Riseley Business Park
Basingstoke Road, Riseley
Berkshire RG7 1NW
Office: +44 (0) 118 984 0610
Fax: +44 (0) 118 984 0611
Email: [email removed] Visit our website at: www.autoscribe.co.uk
Registered in Wales No. 1539748


Description: Description: follow_bird_us-a

Description: Description: Description: http://press.linkedin.com/images/LinkedIn_WebLogo_LowResExample.jpg
**********************************************************DISCLAIMER*****************************************************

The contents of this email are confidential and are intended solely for the use of the individual or company to
whom it is addressed. If you have received this email in error then please accept our apology. If this is the case
we would be obliged if you would contact the sender and then delete this email. Opinions expressed in this email
are those of the individual and do not necessarily represent the opinions of Autoscribe Ltd. Although this email
and any attachments are believed to be free of any virus no responsibility is accepted by Autoscribe Ltd for any
loss or damage arising in any way from the receipt or use of this email or attachments.