Project being built in .Net2.0 not .Net4.0

Topics: Bindings File, Settings Management and SSO
May 14, 2012 at 2:52 PM

Hi

I am having problems trying to build and deploy my solution as I keep getting this error:

  Assembly successfully added to the cache
  "C:\Program Files (x86)\Deployment Framework for BizTalk\5.0\Framework\DeployTools\gacutil.exe" /i "..\Fibonacci.Orchestrations\bin\Debug\Fibonacci.Orchestrations.dll"
  Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1
  Copyright (c) Microsoft Corporation.  All rights reserved.
 
  Assembly successfully added to the cache
  Finished deploying components to GAC.
  Running installutil.exe on components...
  C:\Windows\Microsoft.NET\Framework\v2.0.50727\installutil.exe /ShowCallStack "..\Fibonacci.Schemas\bin\Debug\Fibonacci.Schemas.dll"
  Microsoft (R) .NET Framework Installation utility Version 2.0.50727.5420
  Copyright (c) Microsoft Corporation.  All rights reserved.

Exception occurred while initializing the installation:
  System.BadImageFormatException: Could not load file or assembly 'file:///C:\Projects\Fibonacci\Fibonacci.Schemas\bin\Debug\Fibonacci.Schemas.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded..

It seems that the Fibonacci.Schemas.dll is being built using .net2.0.

If I do a manual build and deploy through VS2010, it's all ok.  Somehow it builds it using .net 4.0

How do I change the framework version to be .net 4.0 for the Fibinacci.Schemas.dll when building the solution?

The project properties say it is already set to build in .Net 4.0.

Any help would be great.

Thanks

:)

Coordinator
May 14, 2012 at 3:54 PM

Do you have your Schemas DLL listed under a Components ItemGroup?  If so, it should be in a Schemas ItemGroup.

Do you have a .NET components assembly that needs InstallUtil.exe to be run against it?  If not, you should not have IncludeInstallUtilForComponents in your .btdfproj.

Thanks,
Tom

May 15, 2012 at 10:18 AM

Hi Tom

Thanks for your reply.  My Schemas DLL is listed under Item group

 <ItemGroup>
    <Components Include="$(ProjectName).Schemas.dll">
      <LocationPath>..\$(ProjectName).Schemas\bin\$(Configuration)</LocationPath>
    </Components>
  </ItemGroup>

I do have another .Net assembly which I wish to add to the Biztalk Resources so I do have the entry

 <IncludeInstallUtilForComponents>true</IncludeInstallUtilForComponents>

Here's my .btdfproj
<?xml version="1.0" encoding="utf-8"?>
<!-- 
  Deployment Framework for BizTalk 5.0
  Copyright (C) 2008-2010 Thomas F. Abraham and Scott Colestock
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Deploy">
  <PropertyGroup>
    <Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
    <Platform Condition="'$(Platform)' == ''">x64</Platform>
    <SchemaVersion>1.0</SchemaVersion>
    <ProjectName>Fibonacci</ProjectName>
    <ProjectVersion>1.0</ProjectVersion>
    <IncludeTransforms>False</IncludeTransforms>
    <IncludeComponents>True</IncludeComponents>
    <IncludeDeploymentTest>False</IncludeDeploymentTest>
    <IncludeSSO>true</IncludeSSO>
    <IncludeInstallUtilForComponents>true</IncludeInstallUtilForComponents>
    <RequireXmlPreprocessDirectives>false</RequireXmlPreprocessDirectives>
    <UsingMasterBindings>true</UsingMasterBindings>
    <ApplyXmlEscape>true</ApplyXmlEscape>
    <DeveloperPreProcessSettings>$(MSBuildProjectDirectory)\EnvironmentSettings\DEV_Settings.xml</DeveloperPreProcessSettings>
  </PropertyGroup>
  <PropertyGroup>
    <!-- Properties related to building an MSI for server deployments -->
    <!-- BizTalk App Version Upgrade -->
    <!--   For each new product release to be deployed to your BizTalk servers: -->
    <!--     1) Increment ProductVersion -->
    <!--     2) Generate a new GUID and update ProductId with the new GUID -->
    <!--   This allows the new MSI to automatically uninstall (not undeploy!) the old MSI and install the new one. -->
    <ProductVersion>1.0.0</ProductVersion>
    <ProductId>b14dc0ce-1668-4458-b595-5fdd27cd1bb8</ProductId>
    <!-- BizTalk App Version Upgrade -->
    <ProductName>Fibonacci for BizTalk</ProductName>
    <Manufacturer>FairyLiquid</Manufacturer>
    <PackageDescription>Fibonacci</PackageDescription>
    <PackageComments>Fibonacci</PackageComments>
    <!-- NEVER change the ProductUpgradeCode. -->
    <ProductUpgradeCode>fc39fa3d-8138-41ef-9ecb-574b9b7073f1</ProductUpgradeCode>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <DeploymentFrameworkTargetsPath>$(MSBuildExtensionsPath)\DeploymentFrameworkForBizTalk\5.0\</DeploymentFrameworkTargetsPath>
    <OutputPath>bin\Debug\</OutputPath>
    <DeployPDBsToGac>false</DeployPDBsToGac>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <DeploymentFrameworkTargetsPath>$(MSBuildExtensionsPath)\DeploymentFrameworkForBizTalk\5.0\</DeploymentFrameworkTargetsPath>
    <OutputPath>bin\Release\</OutputPath>
    <DeployPDBsToGac>false</DeployPDBsToGac>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Server'">
    <DeploymentFrameworkTargetsPath>Framework\</DeploymentFrameworkTargetsPath>
    <!-- Get our PDBs into the GAC so we get file/line number information in stack traces. -->
    <DeployPDBsToGac>false</DeployPDBsToGac>
  </PropertyGroup>
  <ItemGroup>
    <PropsFromEnvSettings Include="SsoAppUserGroup;SsoAppAdminGroup;InputDir;OutputDir" />
  </ItemGroup>
  <ItemGroup>
    <Components Include="$(ProjectName).Processor.dll">
      <LocationPath>..\$(ProjectName).Processor\bin\$(Configuration)</LocationPath>
    </Components>
  </ItemGroup>
  <ItemGroup>
    <Components Include="MessageCreator.dll">
      <LocationPath>..\..\MessageCreator\bin\$(Configuration)</LocationPath>
    </Components>
  </ItemGroup>
  <ItemGroup>
    <Components Include="$(ProjectName).Schemas.dll">
      <LocationPath>..\$(ProjectName).Schemas\bin\$(Configuration)</LocationPath>
    </Components>
  </ItemGroup>
  <ItemGroup>
    <Components Include="$(ProjectName).Orchestrations.dll">
      <LocationPath>..\$(ProjectName).Orchestrations\bin\$(Configuration)</LocationPath>
    </Components>
  </ItemGroup> 
  <ItemGroup>
    <BizTalkHosts Include="FibonacciProcess;FibonacciReceive;FibonacciSend" />
  </ItemGroup>
  <Import Project="$(DeploymentFrameworkTargetsPath)BizTalkDeploymentFramework.targets" />
  <!--
    The Deployment Framework automatically packages most files into the server install MSI.
    However, if there are special folders that you need to include in the MSI, you can
    copy them to the folder $(RedistDir) in the CustomRedist target.
    To include individual files, add an ItemGroup with AdditionalFiles elements.
  -->
  <Target Name="CustomRedist">
  </Target>
</Project>
I've changed the order in which the assemblies are listed in the .btdfproj and now I get the same error
but for a the Processor DLL which is a .NET assembly component not a BizTalk project.

The error is now:

  Assembly successfully added to the cache
  Finished deploying components to GAC.
  Running installutil.exe on components...
  C:\Windows\Microsoft.NET\Framework\v2.0.50727\installutil.exe /ShowCallStack "..\Fibonacci.Processor\bin\Debug\Fibonacci.Processor.dll"
  Microsoft (R) .NET Framework Installation utility Version 2.0.50727.5420
  Copyright (c) Microsoft Corporation.  All rights reserved.
  
  Exception occurred while initializing the installation:
  System.BadImageFormatException: Could not load file or assembly 'file:///C:\Projects\Fibonacci\Fibonacci.Processor\bin\Debug\Fibonacci.Processor.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded..
C:\Program Files (x86)\MSBuild\DeploymentFrameworkForBizTalk\5.0\BizTalkDeploymentFramework.targets(1342,5): error MSB3073: The command "C:\Windows\Microsoft.NET\Framework\v2.0.50727\installutil.exe /ShowCallStack "..\Fibonacci.Processor\bin\Debug\Fibonacci.Processor.dll"" exited with code -1. [C:\Projects\Fibonacci\Deployment\Deployment.btdfproj]
Done Building Project "C:\Projects\Fibonacci\Deployment\Deployment.btdfproj" (Deploy target(s)) -- FAILED.

Build FAILED.

"C:\Projects\Fibonacci\Deployment\Deployment.btdfproj" (Deploy target) (1) ->
(DeployComponents target) -> 
  C:\Program Files (x86)\MSBuild\DeploymentFrameworkForBizTalk\5.0\BizTalkDeploymentFramework.targets(1342,5): error MSB3073: The command "C:\Windows\Microsoft.NET\Framework\v2.0.50727\installutil.exe /ShowCallStack "..\Fibonacci.Processor\bin\Debug\Fibonacci.Processor.dll"" exited with code -1. [C:\Projects\Fibonacci\Deployment\Deployment.btdfproj]

    0 Warning(s)
    1 Error(s)

Do you know what I'm missing?
This is being run on BizTalk Developer, VS2010 SP1.

Thanks
:)


 

May 15, 2012 at 10:21 AM
Edited May 15, 2012 at 10:26 AM

I've just seen that someone else has noted the same issue under the Issue tracker tab above as Id #9399

May 15, 2012 at 11:05 AM
Edited May 15, 2012 at 11:06 AM

The next issue I have is the bindings are being created with &s and amp;

This occurs on the Send and Receive Ports.  An entry of   

 

 <ReceiveLocationTransportTypeData>&lt;CustomProps&gt;

 

gets translated to

 

<ReceiveLocationTransportTypeData>&amp;lt;CustomProps&amp;gt;

 

and cannot be imported as it generates the error

 

Invalid or malformed XML data. (Microsoft.BizTalk.ExplorerOM)

 

Is there a sneaky way of controlling this?

:)

Coordinator
May 15, 2012 at 3:32 PM

Did you start with the Add New Project wizard to create this deployment project?  If not, that's the recommended approach.

Have you downloaded and reviewed the documentation?

Each category of BizTalk assembly has a different ItemGroup.  You have everything listed under Components instead of your orchestrations assembly under Orchestrations, schemas assembly under Schemas and .NET components under Components.

Based on what you've described, I'm guessing that you should simply remove <IncludeInstallUtilForComponents>, unless you have an installer class inside your Processor assembly that needs to run.

Your binding file will work once you remove or set to False the ApplyXmlEscape property.

Please take some time to go through the documentation and samples and follow up here with any questions.

Thanks!
Tom

May 16, 2012 at 9:14 AM

Hi Tom

Thanks for your help. 

Your comments above were much appreciated.

I had copied some lines out of someone elses .btdfproj which caused the problems you stated above.

If vaklues are set to false, do youhave to keep them in th e .btdfproj or can you remove them?
Thanks

Coordinator
May 17, 2012 at 4:21 AM

Do you keep the properties or remove them?  It depends on whether False is or is not the default value for each setting.  You'd have to refer to the main BTDF targets file as a reference (some default values are also noted in the IntelliSense pop-up help).  ApplyXmlEscape defaults to False, as does IncludeInstallUtilForComponents, so you could remove those if you set them to False.

Thanks,
Tom