build Add-ins From msbuild command-line

10453
22
11-29-2011 11:09 AM
LukeBadgerow
New Contributor
I am in the process of putting together a CI Server application (Jenkins) that is currently building my SOA application.  I would like to add a desktop add-in that I am also working on to this server, however in order for that to happen I need to be able to build with msbuild.exe.  When I try and compile my add-in project with msbuild I receive the following error (more specifically, the following comes from Jenkins, but it's the same error locally):

Started by user anonymous
Updating http://subversion-repo/EngineeringServices/DesktopGISUtilities/DOTNET/WaterEditorExtension
At revision 1241
no change for http://subversion-repo/EngineeringServices/DesktopGISUtilities/DOTNET/WaterEditorExtension since the previous build
Path To MSBuild.exe: C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe
Executing command: cmd.exe /C C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe c:\workspace\dotnet\watereditor10\watereditorextension.csproj && exit %%ERRORLEVEL%%
[workspace] $ cmd.exe /C C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe c:\workspace\dotnet\watereditor10\watereditorextension.csproj && exit %%ERRORLEVEL%%
Microsoft (R) Build Engine Version 3.5.30729.1
[Microsoft .NET Framework, Version 2.0.50727.3623]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 11/29/2011 11:20:08 AM.
Project "c:\workspace\dotnet\watereditor10\watereditorextension.csproj" on node 0 (default targets).
Project file contains ToolsVersion="4.0", which is not supported by this version of MSBuild. Treating the project as if it had ToolsVersion="3.5".
C:\Program Files (x86)\MSBuild\ESRI\ESRI.ArcGIS.AddIns.targets(36,5): error MSB4062: The "ValidateAddInXMLTask" task could not be loaded from the assembly ESRI.ArcGIS.AddIns.SDK, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86. Could not load file or assembly 'Microsoft.VisualStudio.Shell.9.0, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, and that the assembly and all its dependencies are available.
Done Building Project "c:\workspace\dotnet\watereditor10\watereditorextension.csproj" (default targets) -- FAILED.

Build FAILED.

"c:\workspace\dotnet\watereditor10\watereditorextension.csproj" (default target) (1) ->
(PrePackageArcGISAddIn target) ->
  C:\Program Files (x86)\MSBuild\ESRI\ESRI.ArcGIS.AddIns.targets(36,5): error MSB4062: The "ValidateAddInXMLTask" task could not be loaded from the assembly ESRI.ArcGIS.AddIns.SDK, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86. Could not load file or assembly 'Microsoft.VisualStudio.Shell.9.0, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, and that the assembly and all its dependencies are available.

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.68
Build step 'Build a Visual Studio project or solution using MSBuild.' marked build as failure
Finished: FAILURE
0 Kudos
22 Replies
LukeBadgerow
New Contributor
so I'll bump myself, since every time I google this I get brought back here.

The error above is actually caused by the version of msbuild I was using.  When I switched to use the DOTNET Framework v4.0 I receive a new and also interesting error.  Side note, I am able to build both of the WPF/ Console applications I have targeted for 10.0. 

C:\Program Files (x86)\MSBuild\ESRI\ESRI.ArcGIS.AddIns.targets(36,5): error MSB
4062: The "ValidateAddInXMLTask" task could not be loaded from the assembly ESR
I.ArcGIS.AddIns.SDK, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc63
1e44ad86. Could not load file or assembly 'Microsoft.VisualStudio.Shell.9.0, Ve
rsion=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified. Confirm that the <Usin
gTask> declaration is correct, that the assembly and all its dependencies are a
vailable, and that the task contains a public class that implements Microsoft.B
uild.Framework.ITask.
Done Building Project "c:\workspace\dotnet\watereditor10\watereditorextension.c
sproj" (default targets) -- FAILED.


Build FAILED.


right now, I believe that the <UsingTask> that the error is referring to comes from the targets file for the Addins.SDK:

  <UsingTask AssemblyName="ESRI.ArcGIS.AddIns.SDK, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86" TaskName="ValidateAddInXMLTask" />


 <Target Name="PrePackageArcGISAddIn">

    <ValidateAddInXMLTask ContentFiles="@(AddInContent)" BuildProjectPath="$(ProjectPath)" AssemblyName="$(TargetFileName)" TargetFrameworkVersion="$(TargetFrameworkVersion)" />  
  </Target>


But that's where I'm stuck.
0 Kudos
AndrewFlanagan
New Contributor II
Did you ever get any resolution on this?  I'm experiencing the exact same problem.
0 Kudos
LukeBadgerow
New Contributor
Did you ever get any resolution on this?  I'm experiencing the exact same problem.


I haven't as yet.  I've worked with it for couple of days here and there, and I forwarded the error message to a friend that works in Redlands but I don't expect to hear from him for a while given the fact that they're in code freeze moving up to 10.1. 

I'm waiting to elevate this to an actual tech services call until I have the time to burn explaining what I'm trying to do to teir-1 support.  As I hear anything I'll let you know.
0 Kudos
JuhoVainio
Occasional Contributor
I have this problem, too.

I've used the assembly binding log viewer (can be found at C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin) to analyze what happens when the ValidateAddInXMLTask gets called. The log showed up like this:
*** Assembly Binder Log Entry  (13.4.2012 @ 9:21:45) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = xxxxx
LOG: DisplayName = Microsoft.VisualStudio.Shell.9.0, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 (Fully-specified)
LOG: Appbase = file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MSBuild.exe
Calling assembly : ESRI.ArcGIS.AddIns.SDK, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.VisualStudio.Shell.9.0, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Microsoft.VisualStudio.Shell.9.0.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Microsoft.VisualStudio.Shell.9.0/Microsoft.VisualStudio.Shell.9.0.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Microsoft.VisualStudio.Shell.9.0.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Microsoft.VisualStudio.Shell.9.0/Microsoft.VisualStudio.Shell.9.0.EXE.
LOG: All probing URLs attempted and failed.


I also found that the missing file Microsoft.VisualStudio.Shell.9.0.DLL is part of the Visual Studio SDK. So I downloaded the VS2010 SDK and installed it. Then I had to manually copy the file to the folder C:/Windows/Microsoft.NET/Framework64/v4.0.30319/ (the dll didn't register to the GAC).

Now I'm stuck with error:
C:\Program Files (x86)\MSBuild\ESRI\ESRI.ArcGIS.AddIns.targets (109): Missing required ArcGIS component(s). Make sure you have a valid ArcGIS runtime install.


with the log entry:
*** Assembly Binder Log Entry  (13.4.2012 @ 10:42:38) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = xxxxxx
LOG: DisplayName = ESRI.ArcGIS.AddIns.SDK.resources, Version=10.0.0.0, Culture=en-US, PublicKeyToken=8fc3cc631e44ad86
 (Fully-specified)
LOG: Appbase = file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MSBuild.exe
Calling assembly : ESRI.ArcGIS.AddIns.SDK, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: ESRI.ArcGIS.AddIns.SDK.resources, Version=10.0.0.0, Culture=en-US, PublicKeyToken=8fc3cc631e44ad86
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/en-US/ESRI.ArcGIS.AddIns.SDK.resources.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/en-US/ESRI.ArcGIS.AddIns.SDK.resources/ESRI.ArcGIS.AddIns.SDK.resources.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/en-US/ESRI.ArcGIS.AddIns.SDK.resources.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/en-US/ESRI.ArcGIS.AddIns.SDK.resources/ESRI.ArcGIS.AddIns.SDK.resources.EXE.
LOG: All probing URLs attempted and failed.


I have no idea where to get the ESRI.ArcGIS.AddIns.SDK.resources.DLL from!
0 Kudos
AndrewFlanagan
New Contributor II
To give some more details of my issues (which is the same and is still unresolved):

I only have this issue on our Continuous Integration agent server. We're using TeamCity to perform the build. We're using their solution builder and simply pointing to our .NET solution. Interestingly, if I load the solution on the same box into Visual Studio 2010, I can build with no errors -- it's only when TeamCity is calling that it has this odd behavior.
0 Kudos
JuhoVainio
Occasional Contributor
To give some more details of my issues (which is the same and is still unresolved):

I only have this issue on our Continuous Integration agent server. We're using TeamCity to perform the build. We're using their solution builder and simply pointing to our .NET solution. Interestingly, if I load the solution on the same box into Visual Studio 2010, I can build with no errors -- it's only when TeamCity is calling that it has this odd behavior.


Yes, we're having exactly the same behaviour. CI --> errors, VS2010 --> no errors.
0 Kudos
LukeBadgerow
New Contributor


I have no idea where to get the ESRI.ArcGIS.AddIns.SDK.resources.DLL from!


Have you managed to track down this dll?  I pulled out  the "parent" ESRI.ArcGIS.AddIns.SDK.dll by reinstalling the ArcObjects .NET SDK as described in this forum thread:

http://forums.arcgis.com/threads/118-Beta-10-.Net-Untrusted-component

but I just went through another quick search of my file system and didn't see the .resources.dll anywhere.  I'm going to keep looking though.  thanks for posting your logs!
0 Kudos
LukeBadgerow
New Contributor
-- it's only when TeamCity is calling that it has this odd behavior.


As I've asked around with some of the other AO developers I know I am often met with the blank stare of "why would you want to use an external build tool".  I was really starting to fear that trying to implement anything like this was going to brand me some kind of java developing freak.
0 Kudos
AndrewFlanagan
New Contributor II
[SOLVED]

I was able to finally resolve this on our TeamCity CI server.

1) Download the Visual Studio 2010 SDK SP1 from Microsoft:
http://www.microsoft.com/en-us/download/details.aspx?id=21835

2) Install on the CI server

3) Grab the Microsoft.VisualStudio.Shell.9.0.dll file from under <SDK Install Folder>\VisualStudioIntegration\Common\Assemblies\v2.0 (I believe the default path is C:\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v2.0)

4) Throw it in the GAC.

5) Have your CI rebuild!

I did run into another snag that's related to the ArcGIS build environment.We were running the TeamCity Build Agent service as LocalSystem. Since ESRI wants to do some funky user-based installation post-build, I had to run the server as a "real user". I'm not sure of the details and quite frankly was just happy to get it working finally.

Let me know if this works for you guys -- I'm curious to see if there are other issues.