sjors miltenburg sjors miltenburg - 1 month ago 22
C# Question

error when building office addin with commandline

project builds just fine in visual studio 2012 (V11) but does not build when building it with msbuild.exe through the command line

error received:


error MSB4062: The "InitializeDefaultProperties" task could not be
loaded from the assembly Microsoft.VisualStudiols.Office.BuildTasks,
Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
Could not load file 'Microsoft.VisualStudio.Tools.Office.BuildTasks,
Version=10.0.0.0

Answer

Turns out the project is a outlook 2010 addin. The version of Microsoft.VisualStudiols.Office.BuildTasks.dll I have in my gac is v11 instead of v10 that it seems to require (by default).

Why visual studio CAN build the project probably has something to do with the following line in the csproj file:

<Import Project="$(VSToolsPath)\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" Condition="'$(VSToolsPath)' != ''" />

(I don't know where it gets the vstoolspath variable from)

I solved this by using an extra build config item /p:VisualStudioVersion=11.0 used like so:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
/p:Configuration=Debug /p:VisualStudioVersion=11.0
"$base_dir\OutlookAddin\OutlookAddin.csproj"
Comments