msbuild fails to compile vsto project - msbuild

We recently installed a new development environment (Windows 10) from scratch with Visual Studio 2017 but we cannot manage to make msbuild compile a Microsoft Office Addin for Word (vsto).
Within the Visual Studio installer we made sure to include the required components for Office Development.
It throws the following error (german translated to english)
error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" was not found. Also, tried to find "OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" [...]
However, the project builds fine within Visual Studio.
On the old system, everything works fine, and i cannot remember having to configure anything at all.

You need to install Office build tools when installing Build Tools for Visual Studio 2017

In my case, I managed to get around the issue by copying the folder
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio
from the development environment (the old environment in your case) to
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio
on the build environment (the new environment in your case). I would have thought that one should be able to simply get the relevant targets from the Build Tools for Visual Studio 2017 but that appears not to be the case.

After reinstalling everything it works now.
I guess back then when we set up this machine, the build tools setup was bugged or something.
Now we could install everything we needed for the buildtools using the visual studio installer and it works like a charm.

Okay, so I've worked through this one now. The problem was caused by me using Windows\Microsoft.NET\Framework64\v4...\Msbuild.exe.
It looks as though running msbuild from this location results in it not being able to implicitly locate many of the assemblies and build utilities required to build a VSTO project.
I resolved the problem by switching to using C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe

Related

Microsoft.VisualStudio.Tools.Office.targets missing

I am installing a build agent on a virtual machine (using GoCD) and my goal is trying to keep it as light as possible, i.e., installing only MSBuild and avoid installing visual studio.
One of my projects uses OfficeTools and when compiling the build I get the following error:
C:\GoAgent1\pipelines\ProjectRepo\Office\MyProject.Office.Excel2007.UnderwritingNotes\MyProject.Office.Excel2007.UnderwritingNotes.csproj(365,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 declaration is
correct, and that the file exists on disk.
OfficeTools\Microsoft.VisualStudio.Tools.Office.targets doesn't exist!
For that I will need to install "Office Tools for Visual Studio" which depends on Visual Studio (in this case VS2015 or 14.0).
One solution is copying this folder from my development machine but is sounds a bit messy!
So I was wondering if there are standalone versions that I can plug into MSBuild without installing Visual Studio. Any suggestion?

TeamCity/.sqlproj build via MSBuild -- FAILED

It all started with the VS2017 runner type within TC. It was failing without any errors or hints (except the (default targets) -- FAILED. message on the solution level). I narrowed it down to the .sqlproj'ects. These are not building via MSBuild, they do compile perfectly within VS2017 on the build agent.
I was blaming SSDT for it... but I guess I checked everything. This is the problem which bubbles up to the solution level within the TC build:
I noticed that for VS2017 SSDT comes with the VS setup. The "Workload" "Data storage and processing" is installed and so is "SQL Server Data Tools" under "Individual components".
I noticed on https://learn.microsoft.com/EN-US/sql/ssdt/download-sql-server-data-tools-ssdt the sentence "If you are using SSDT with Visual Studio 2017, install the AS and RS components". Did it. Nothing changed. SSDT is also installed separately for previous versions.
This stack is related but it didn't help me.
Any other ideas?
I came a step further. Beside VS the Build Tools are installed as well on the build agent and TeamCity's runner for VS2017 obviously uses MSBuild from the Build Tools.
As you can see above I was reproducing the issue with MSBuild from the Build Tools as well.
If I pick the MSBuild "version" of VS2017 it works like a charm (as it does right within VS).
To make it short:
DOES NOT WORK
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin
WORKS
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin
I found a blog post from Lukie Briner, his last paragraph pointed me to the solution (thank you buddy!).
Still don't know why/how this can happen, maybe it is related to the order of the installations of Build Tools, SSDT, Visual Studio etc.?
The reason: SSDT was missing in the Build Tools and its version of MSBuild.
What I have done:
Copy the SSDT folder from
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0
to
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0.
WOW! I finally see a REAL error message:
Now I had to copy SQLDB and SQLEditor (I think SQLCommon already existed in the destination folder, if not it should also be copied) from
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft
to
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\Extensions\Microsoft
and BOOM...
And yes, the VS2017 runner from TeamCity is also happy with it.
Seems like the issue with Build Tools and SSDT has been solved now and you don't have to mess with manual copy of targets directories anymore (Visual Studio Build Tools 2017 v15.9.8).
Just open the Visual Studio Installed on the build agent server
Modify Build Tools installation
Select to install the "Data storage and processing tools"
Modify
Build should work now.

Visual Studio 2015 - a lot of Packages are missing

So I recently bought a new computer. And now I wanted to install visual studio 2015. So I did. But now the problem is that i cant create a new project because i cant select a vb.net form or anything else and also im getting these error messages saying:
The 'ErrorListPackage' package did not load correctly
The'VisualStudioPackage' package did not load correctly
The Microsoft.visual studio package did not load correctly
anyone has a solution for this? because I'm kinda getting a bit frustrated now.
I tried a complete uninstall and install and it didnt work. I tried copying folders from my laptop to my new pc but also that didn't work. Also switching frameworks doesn't do anything. I also never experienced this problem before but can this problem occure because I have 2 drives?? Seems odd but I think I'm also going to do an uninstall again and then try the .iso installer and see if that helps.
So this is how I fixed it for myself.
I removed all files and folders that are linked to visual studio
C:\Program Files\Microsoft Visual Studio 12.0
C:\Program Files (x86)\Microsoft Visual Studio 12.0
C:\Program Files (x86)\Microsoft Visual Studio 14.0
C:\Users\name\AppData\Roaming\Microsoft\VisualStudio
C:\Users\name\AppData\Local\Microsoft\VisualStudio
C:\Users\name\AppData\Local\Microsoft\VisualStudio Services
C:\Users\name\AppData\Local\Microsoft\VSCommon
C:\Users\name\AppData\Local\Microsoft\VsGraphics
After I deleted all of those folders I deleted the regkeys located:
HKLM > SOFTWARE > Microsoft > Visual Studio
After that I started the visual studio installer with admin rights.
And now I can create a project :)
This usually indicates an issue with an extension which ships with some dependent assemblies which Visual Studio itself (or another extension) also depends on. When these dependencies are different versions, it's not predictable which version will load.
To solve your problem, first disable your extensions and add-ins, then close Visual Studio, clear the ComponentModelCache folder under:
C:\Users\{username}\AppData\Local\Microsoft\VisualStudio\12.0\ComponentModelCache
And start Visual Studio again.
This should clear the immediate issue.
Now enable each extension one-by-one restarting Visual Studio every time to see if the issues come back.
To dive deeper into the underlying issue, you could look into all the extensions under these folders:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions
C:\Users\{user}\AppData\Local\Microsoft\VisualStudio\12.0\Extensions
Look for assemblies from Microsoft itself (commonly found are Microsoft.TeamFoundation.* and Microsoft.VisualStudio. in folders containing an extension that did not originate from Microsoft. These extensions are common culprits for these issues.
If you want to dig deeper, consider using fuslogvw from the Windows SDK to see which assemblies are loaded and which exact versions they are. You can also look into the Visual Studio logs after the issue surfaces to see what underlying cause there may be. The log should be available under:
%AppData%\Microsoft\VisualStudio\14.0\ActivityLog.XML

Entity Framework in Visual Studio 2013 library not found

I get a rather unusual error in Visual Studio 2013 in Visual Basic when trying to work with Entity Framework. This doesn't matter whether I work with an existing project or create a new one. It started to happen when I changed to a new PC with Win 8.1.
I create a new model using the wizard from a database. It creates the diagram very nicely. However, I get an compilation error telling the library EntityFramework.dll doesn't exist. However, the only thing is that the path to EntityFramework.dll is wrong (Looks like: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\..\IDE\EntityFramework.dll). The address, however, would be D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE. Where would I change that value?
Ueli
Apparently when reinstalling Visual Studio to a different drive the %VS120COMNTOOLS% environment variable is not updated correctly and points to the folder on the drive where VS was originally installed. The template for generating DDL SQL is using the %VS120COMNTOOLS% environment variable to find assemblies it needs to generate the code. Since the variable is pointing to a folder that no longer contains the necessary files the T4 template transformation fails.
Troubleshooting:
Open the developer command prompt for VS2013
set the variable manually to point to the correct location (e.g.
set VS120COMNTOOLS="D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\")
start VS from the command prompt by executing devenv
verify if things now work
(Note that if you follow the above steps to set the variable it will only work for VS instances started from this command prompt.)
If the above works go to the computer properties (e.g. in Win 8/Win 8.1 type "This PC" in the search window), right click on the icon and select "Properties", go to the "Advanced" tab and click the "Environment Variables" button, then in the "System variables" window find the VS120COMNTOOLS variable, double click (or click the "Edit" button) and fix the variable so that it points to the right folder.
Don't forget the last backslash after Tools... C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools <---- will not work, but... C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\ <--- will work
It might look funny but I encounter the same issue (with windows 8.1) but none of the suggested methods worked for me!!
I checked my environment variables it had the correct path but when I tested it with explorer (typed %VS120COMNTOOLS% in explorer's address bar) it does not showed up!! Rather it said
"windows cannot find %VS120COMNTOOLS% make sure you typed the name correctly"
So what I did was I just deleted the variable and recreated it with the exact same path
and after rebuild the error gone!!!
So if you guys have the same issue give it a go
In my case, it was a permission issue and not related to the environment variable file path as the path was correct in my case.
So what I did is added permissions to my current user on the whole visual studio installation folder and then launched Visual Studio as administrator. I re-generated my Model and it worked!
I had this problem with VS2013 on Windows 8.1. I solved the problem by copying
EntityFramework.dll and Microsoft.Data.Entity.Design.dll
from C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE
to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools
The files are in both locations and now everything works fine.
I had to delete my DB Entity Model and start over again to get things working.
It's probably just an MS coding error making VS2013 look in the wrong place.
I had this problem with VS2013 on Windows Server 2012R2. Two drives (C and D). I tried repairing and uninstall-reinstall but that didn't fix anything. It was hacky but I got it to work.
First I changed the system variables to go from D to C. To do this, go to Control Panel --> System and Security --> System. On the left hand side you will see Advanced System Settings. On the bottom of the Advanced tab you see Environment Variables. I had to edit VS120COMNTOOLS to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools. It previously was D:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools.
Then I copied the EntityFramework.dll and Microsoft.Data.Entity.Design.dll from C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\IDE. If the IDE folder doesn't exist then create one. That is what I had to do. Seems so strange but it works!
I had to delete the current edmx in my project, readd it, and restart VS. Such a wierd problem and took me quite a while to piece together multiple stackoverflow articles to get the whole problem solved.
The following path of %VS120COMNTOOLS% is working for me:
set VS120COMNTOOLS="D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\"
I also faced the same issue. I have my VS2012 at "D:\Program Files (x86)\".
I tried to set the common folder for VS using the following set command from VS2012 command Prompt.
set VS120COMN="D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7"
This resolved the issue for me.

Wix darice.cub file missing when building from visual studio 2010

We have created a simple wix project for a basic windows application. Everything builds fine and the MSI is produced.
However, switching to Release gives the following error message;
light.exe(0,0): error LGHT0222: The cube file'C:\Users\julius\AppData\Local\assembly\dl3\3V768E95.XWA\CYQG3JK6.XHT\2b4730b4\00186b06_b0b7cb01\darice.cub' cannot be found. This file is required for MSI validation.
If I run our build script which uses msbuild to build the solution everything works fine. So I am thinking it got something to do with the visual studio environment. I have tried making a simple solution with a wix installer and that solution works fine both in debug and release.
Im running this on Windows 7 64 bit box using VS 2010 SP1.
Any ideas what I should look for?
Same config here. I just copied it from C:\Program Files (x86)\Windows Installer XML v3.6\bin to that location and the error is gone. Weird...
I was able to fix this in VS2013 by simply restarting Visual Studio