none
MSBuild ver 14.0 - error MSB4018: The "SetOffice2007AddInRegistration" task failed unexpectedly RRS feed

  • General discussion

  • Hi everyone,

    I have a Word 2007 Addin project that I converted to Word Addin 2016. The project is built successfully in VS 2015 and the Addin works fine in Word 2016. However, I have a problem when I try to build this project on a TFS 2015 Build server. The build is failed with the error MSB4018 (see the error details below). I know this error happens sometimes in Visual Studio builds and cleaning HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\VSTO\SolutionMetadata registry keys helps. But it does not in my case. I cleaned up all keys for the account that runs the MSBuild service on the TFS build server but the error still persists.

    So, I decided to create a brand new Word 2016 Addin project in VS2015 and built it on my TFS build server. Note, the project code was completely auto generated by Visual Studio. I did not change anything. To my surprise, the MSBuild build  failed exactly with the same error as my original project. Then, I run MSBuild from the MSBuild Command Prompt on the build server using the command line taken from the TFS Build Diagnostic records. This run produced a detailed diagnostic log that I compared with the log produced from Visual Studio build. The logs were difficult to compare because they were completely different. However, the major difference that I noticed was the MSBuild build log did not have the "UnregisterOfficeAddin" target step. I assume that "MSBuild "RegisterOfficeAddin" target step failed because of this omission. It failed with the MSB4018 error (see the error details in the bottom of this question).

    In contrary, the VisualStudio log had both targets steps "UnregisterOfficeAddin" and "RegisterOfficeAddin" completed successfully. By the way, both steps use the same "SetOffice2007AddInRegistration" task to register and unregister Word Addin in the Windows registry.

    My question is if anyone has experienced the same error in Office Addin MSBuild builds? How did you deal with it?

    Thank you.

    The error details:

    08:46:24.576     2>Target "RegisterOfficeAddin: (TargetId:66)" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" from project "C:\Builds\12\A_TFSBuildWordAddin\A_BuildWordAddin\src\A_BuildWordAddin.csproj" (target "PrepareForRun" depends on it):
                       Using "SetOffice2007AddInRegistration" task from assembly "Microsoft.VisualStudio.Tools.Office.BuildTasks, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
                       Task "SetOffice2007AddInRegistration" (TaskId:43)
                         Task Parameter:Url=C:\Builds\12\A_TFSBuildWordAddin\A_BuildWordAddin\bin\A_BuildWordAddin.vsto (TaskId:43)
                         Task Parameter:AddInName=A_BuildWordAddin (TaskId:43)
                         Task Parameter:OfficeApplication=Word (TaskId:43)
                         Task Parameter:FriendlyName=A_BuildWordAddin (TaskId:43)
                         Task Parameter:Description=A_BuildWordAddin (TaskId:43)
                         Task Parameter:LoadBehavior=3 (TaskId:43)
    08:46:24.592     2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(315,9): error MSB4018: The "SetOffice2007AddInRegistration" task failed unexpectedly.\r [C:\Builds\12\A_TFSBuildWordAddin\A_BuildWordAddin\src\A_BuildWordAddin.csproj]
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(315,9): error MSB4018: System.Runtime.InteropServices.COMException (0x800703F0): An attempt was made to reference a token that does not exist. (Exception from HRESULT: 0x800703F0)\r [C:\Builds\12\A_TFSBuildWordAddin\A_BuildWordAddin\src\A_BuildWordAddin.csproj]
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(315,9): error MSB4018:    at Microsoft.VisualStudio.Tools.Office.Runtime.Interop.VSTOEENativeMethods.GetVSTOEEHandle()\r [C:\Builds\12\A_TFSBuildWordAddin\A_BuildWordAddin\src\A_BuildWordAddin.csproj]
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(315,9): error MSB4018:    at Microsoft.VisualStudio.Tools.Office.Runtime.Interop.VSTOEENativeMethods.GetSolutionMetadata(String solutionInfoString)\r [C:\Builds\12\A_TFSBuildWordAddin\A_BuildWordAddin\src\A_BuildWordAddin.csproj]
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(315,9): error MSB4018:    at Microsoft.VisualStudio.Tools.Applications.OfficeSolutionMetadata..ctor(String manifestLocation)\r [C:\Builds\12\A_TFSBuildWordAddin\A_BuildWordAddin\src\A_BuildWordAddin.csproj]
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(315,9): error MSB4018:    at Microsoft.VisualStudio.Tools.Office.Runtime.AddInRegistryKeyManager.RegisterAddIn(Uri manifestUri, String addInName, String officeApplication, String friendlyName, String description, Int32 loadBehavior, String compatibleFrameworkXML, Boolean runLocal)\r [C:\Builds\12\A_TFSBuildWordAddin\A_BuildWordAddin\src\A_BuildWordAddin.csproj]
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(315,9): error MSB4018:    at Microsoft.VisualStudio.Tools.Office.BuildTasks.SetOffice2007AddInRegistration.Execute()\r [C:\Builds\12\A_TFSBuildWordAddin\A_BuildWordAddin\src\A_BuildWordAddin.csproj]
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(315,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()\r [C:\Builds\12\A_TFSBuildWordAddin\A_BuildWordAddin\src\A_BuildWordAddin.csproj]
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(315,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [C:\Builds\12\A_TFSBuildWordAddin\A_BuildWordAddin\src\A_BuildWordAddin.csproj]
                       Done executing task "SetOffice2007AddInRegistration" -- FAILED. (TaskId:43)
    08:46:24.592     2>Done building target "RegisterOfficeAddin" in project "A_BuildWordAddin.csproj" -- FAILED.: (TargetId:66)

    Monday, May 23, 2016 12:23 AM

All replies