VSTO – Visual Studio Tools for Office

Jordi Romero's Avatar

Jordi Romero

25 Aug, 2015 02:34 PM

Hello, I'm trying to build a repo in AppVeyor but it apparently fails because it doesn't find the VSTO. I've seen in other support threads that people managed to do it but I'm not sure if I need to configure something or I just need to install them (and don't know how) in a before script.

> C:\projects\redbooth-outlook\Redbooth.Outlook\Redbooth.Outlook.csproj(432,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
 

Thanks for your help!

best,

Jordi

  1. Support Staff 1 Posted by Feodor Fitsner on 26 Aug, 2015 07:42 AM

    Feodor Fitsner's Avatar

    Hi Jordi,

    Last time I tried the following worked.

    On your developer machine with VS 2013 and VSTO installed (and provided 7z.exe is in PATH):

    7z a c:\projects\vsto-pack.zip "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Tools.Applications.BuildTasks.dll"
    7z a c:\projects\vsto-pack.zip "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.VisualStudio.Tools.Office.BuildTasks\v4.0_12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Tools.Office.BuildTasks.dll"
    
    7z a c:\projects\vsto-pack.zip "Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets"
    7z a c:\projects\vsto-pack.zip "Program Files\MSBuild\Microsoft.VisualStudio.OfficeTools.targets"
    7z a c:\projects\vsto-pack.zip "Program Files\Reference Assemblies\Microsoft\VSTO40\*"
    7z a c:\projects\vsto-pack.zip "Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\*"
    7z a c:\projects\vsto-pack.zip "Program Files (x86)\Microsoft SDKs\Windows\v8.1A\Bootstrapper\Packages\VSTOR40\*"
    
    reg export "HKLM\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\VS11VSTOCommonPIA" c:\projects\vsto1.reg
    reg export "HKLM\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\VS11VSTOOffice14PIA" c:\projects\vsto2.reg
    reg export "HKLM\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\VS11VSTOOffice15PIA" c:\projects\vsto3.reg
    reg export "HKLM\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\VSTO 4.0 Reference Assemblies" c:\projects\vsto4.reg
    
    7z a c:\projects\vsto-pack.zip c:\projects\*.reg
    

    You should get c:\projects\vsto-pack.zip with bunch of assemblies and reg files inside. Upload that zip to somewhere (FTP, Azure blob, AWS S3, etc.)

    Next, we'll assume zip URL is http://myserver.com/vsto-pack.zip.

    To download package on server add this to build script (or appveyor.yml):

    appveyor DownloadFile http://myserver.com/vsto-pack.zip
    

    This will download package to the root of build folder.

    Unpack it to C: thus assemblies go to their original locations:

    7z x -oC:\ vsto-pack.zip
    

    First two assemblies with MSBuild tasks should be put to GAC on build server:

    "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil" /i C:\Microsoft.VisualStudio.Tools.Applications.BuildTasks.dll
    "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil" /i C:\Microsoft.VisualStudio.Tools.Office.BuildTasks.dll
    

    and finally import registry keys:

    reg import C:\vsto1.reg
    reg import C:\vsto2.reg
    reg import C:\vsto3.reg
    reg import C:\vsto4.reg
    

    I can't check that locally now as I don't have VSTO installed, but I hope you got the idea.

  2. 2 Posted by roberto.huertas on 29 Oct, 2015 05:12 PM

    roberto.huertas's Avatar

    Hi Feodor,

    I've followed the steps you provided but I'm getting an error:

    C:\projects\redbooth-outlook\Redbooth.Outlook.sln" (default target) (1) ->
    "C:\projects\redbooth-outlook\Redbooth.Outlook.Test\Redbooth.Outlook.Test.csproj" (default target) (5) ->
    "C:\projects\redbooth-outlook\Redbooth.Outlook\Redbooth.Outlook.csproj" (default target) (2:2) ->
      C:\projects\redbooth-outlook\Redbooth.Outlook\Redbooth.Outlook.csproj(475,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
     
        0 Warning(s)
        2 Error(s)
     
    Time Elapsed 00:00:04.16
    Command exited with code 1

    Is it a problem with the Office version (provided your example was working with v12.0? Or maybe I have to copy the target file to the Program files path?

    Thank you for your help.

    Best regards,

    Roberto.

  3. Support Staff 3 Posted by Feodor Fitsner on 29 Oct, 2015 11:59 PM

    Feodor Fitsner's Avatar

    Yes, that "recipe" was for VS 2013 (12.0) and you could adopt it for VS 2015 (14.0). I guess there would be not only paths to assemblies and target files, but different strong assembly versions as well.

  4. 4 Posted by roberto.huertas on 30 Oct, 2015 09:39 AM

    roberto.huertas's Avatar

    Hi Feodor,

    I copied the .targets files and now I'm getting this error:

     C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(264,9): error MSB3482: An error occurred while signing: Invalid provider type specified.

    I'm not really sure if it's related to the Clickonce certificate or it's still related to the previous VSTO dlls issues.

    I've signed several Clickonce packages before in AppVeyor wihout any problem but in this case, the certificate had a .p12 extension instead of .pfx. I just changed the extension but I suspect (be looking a the error code above) that it has to do with some sort of server incompatibility.

    Do you know anything about this?

    Kind regards,
    Roberto.

  5. 5 Posted by roberto.huertas on 30 Oct, 2015 09:53 AM

    roberto.huertas's Avatar

    Hi Feodor,

    find attached what I have in my vsto-pack.zip.
    I'm going to try to copy all the other folders and files to its original location and let you know if it works.

    If you have any other idea, please let me know.

    Best regards,
    Roberto

  6. 6 Posted by roberto.huertas on 30 Oct, 2015 01:37 PM

    roberto.huertas's Avatar

    Hi Feodor,

    I've got it working!

    I will summarize the process later in another post

  7. Support Staff 7 Posted by Feodor Fitsner on 30 Oct, 2015 01:45 PM

    Feodor Fitsner's Avatar

    Fantastic! :) looking forward to see your solution!

    - Feodor

  8. 8 Posted by roberto.huertas on 30 Oct, 2015 02:58 PM

    roberto.huertas's Avatar

    Hi Feodor,

    I've confirmed that the previous issue is related to the certificate:

    (VisualStudioForApplicationsBuild target) ->
      C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(264,9): error MSB3482: An error occurred while signing: Invalid provider type specified.

    If I use another certificate it works ok. Do you have any insights on this matter?

    I'll take a look at it too.

    Best regards,
    Roberto.

  9. 9 Posted by roberto.huertas on 30 Oct, 2015 03:44 PM

    roberto.huertas's Avatar

    Hi Feodor,

    I have fixed the issue transforming the .p12 file to pfx and it's working.

    Best regards,

    Roberto

  10. Support Staff 10 Posted by Feodor Fitsner on 30 Oct, 2015 04:35 PM

    Feodor Fitsner's Avatar

    Great! Could you please share final script/solution? Thank you!

  11. 11 Posted by roberto.huertas on 06 Nov, 2015 06:36 PM

    roberto.huertas's Avatar

    Hi Feodor,

    please find here the whole explanation of my case and the solution I found to make it work:
    http://codecoding.com/using-appveyor-to-build-a-vsto-project/

    Best regards,
    Roberto.

  12. Support Staff 12 Posted by Feodor Fitsner on 06 Nov, 2015 06:44 PM

    Feodor Fitsner's Avatar

    Looks great, thank you very much!

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac