Home » MS CRM4 | MS CRM | MSBuild

A fix for the MSCrm 4 Developer toolkit devbuild.bat not building

10. February 2010 by Dave Hawes 0 Comments

I have just been setting up a new Crm project using the MS Crm4 Developer toolkit. Hats off to the guys at MCS, its a great bit of work and is packed full of amazing features which if used properly will ensure extra quality and best practice in the development of a Crm4 solution.

However I did have a bit of a problem with it which I have managed to fix – the default DevBuild.bat MSBuild script would not register my plugins if I ran my Crm server on any port other than 80!

I had followed the documentation about changing the server names etc. but whenever it tried to register my plugins the build failed.

It turns out that the MSCrm 4 Developer toolkit will only play nicely out of the box if you are running Crm on port 80, I am running on port 5555 though! After digging through the Plugin deployment tool source code I noticed that if the “CrmServiceAddress” was not specified then it made the url up from the CrmServiceServer but this did not include the port. Therefore the solution was to pass in the full Crm Service Address.

So the fix is this:

Edit the <YourSolutionName>.Common.targets file in the following places (changes are in red)

Here:

<!-- CRM Server Settings -->
<PropertyGroup>
  <CrmOrganizationName>MyCrmOrg</CrmOrganizationName>
  <CrmServiceServer>localhost</CrmServiceServer>
  <CrmServiceAddress>http://localhost:5555/MSCRMServices/2007/CrmService.asmx</CrmServiceAddress>
  <CrmServiceTimeout>120000</CrmServiceTimeout>
  <CrmServerBinAssemblyDir>C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly</CrmServerBinAssemblyDir>
  <ForceSynchronousPlugins>true</ForceSynchronousPlugins>
  <PluginDeveloperArguments Condition="'$(ForceSynchronousPlugins)' == 'true'">/sf</PluginDeveloperArguments>
</PropertyGroup>

Here:

<UKDynamics.MSBuildTasks.Crm4.Plugins.RegisterSolution
     OrganizationName="$(CrmOrganizationName)"
     ServiceAddress="$(CrmServiceAddress)"
     ServerName="$(CrmServiceServer)"
     Protocol="$(CrmServiceProtocol)"
     Timeout="$(CrmServiceSolutionTimeout)"
     RegisterFile="%(CrmPluginSolution.FullPath)"
     WorkingDirectory="$(CrmServerBinAssemblyDir)" >
     <Output TaskParameter="Duplicates" PropertyName="DuplicatePlugins"/>
   </UKDynamics.MSBuildTasks.Crm4.Plugins.RegisterSolution>

And Here:

<!-- Unregister a Plugin Solution -->
<Target Name="UnregisterCrmSolution"
        Condition="Exists('$(IntermediateOutputPath)PluginRegister.cache')" >
  <Message Text="Unregistering Crm Solution ... " Importance="high" />
  <UKDynamics.MSBuildTasks.Crm4.Plugins.UnregisterSolution
    OrganizationName="$(CrmOrganizationName)"
    ServiceAddress="$(CrmServiceAddress)"
    ServerName="$(CrmServiceServer)"
    Timeout="$(CrmServiceTimeout)"
    PluginAssemblyName="$(AssemblyName)"
    />

  <Microsoft.Build.Tasks.Delete Files="$(IntermediateOutputPath)PluginRegister.cache" />
</Target>

Then it seems to work and you can set any port number you want.

Comments are closed