MSBuild 15 missing after installation - msbuild

I have recently upgraded to VS2017 and building with TeamCity. I have a new project that I need to build using TeamCity.
I tried to install MS Build on the CI server from the following link https://www.visualstudio.com/downloads/ it said that it has successfully installed it. Restarted the CI server trying to build the project and still cannot find the new Build tools.
I checked under C:\Program Files (x86)\MSBuild\15.0\ but I dont see the MSBuild.exe

MSBuild 15 missing after installation
If you want use MSBuild without install Visual Studio, you should download and install vs_BuildTools.exe from below link:
https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15#
After installation complete, you will find the MSBuild.exe under the path:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin
For more detail information, you can refer to: How can I install the VS2017 version of msbuild on a build server without installing the IDE?

MSBuild is now local to Visual Studio 2017
and multiple versions can be installed side-by-side (e.g. build tools, previews, community + enterprise, etc.)
So a path to msbuild.exe could look like:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin

Related

Using MSBuild to build SSDT projects with VS2017 fails

I am trying to set up continuous integration of .sqlproj SSDT projects on our windows server 2016 server.
In order to do this I have installed VS2017 and SSDT tools onto the server to get the required tools. I have also installed MS build tools 2017.
The issue I am currently having is regarding what looks to be miss-matched versions of installed ms build tools and ssdt.
The command i am using to run the build is as follows:
C:\\Windows\Microsoft.NET\\Framework64\\v4.0.30319\\MSBuild.exe /p:VisualStudioVersion=15.0 /property:MSBuildExtensionsPath="C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\MSBuild\\" /property:VsInstallRoot="C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\" DPAP-SQL-Slim.sln
The two switches passed there are to set two environment parameters that the .sqlproj file is expecting to find when run through Visual studio. This is done because MSBuild does not supply them by default.
The error i am currently getting is as follows:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets(477,5): error MSB4062: The "SqlModelResolutionTask" task could not be loaded from the assembly C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\Common7\IDE\Extensions\Microsoft\SQLDB\Dac\140\Microsoft.Data.Tools.Schema.Tasks.Sql.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=15.1.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, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
Now, i can see from running the command: gacutil /l in the VS2017 command prompt that the apparently installed version of the Microsoft.Build.Utilities.Core dll is v14: Microsoft.Build.Conversion.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
Am i missing something key here? It appears that installing build tools 2017 did not in-fact update the GAC and register the correct DLLs.
Do not use the msbuild.exe included in .NET Framework (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe). It is old and does not support some features of newer msbuild versions.
Always use the version of MSBuild installed with visual studio or the build tools. Depending on the version of VS installed, this could be
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe
Starting in VS 2017, MSBuild is also not installed system-wide but many versions (e.g. VS 2017 preview versions, different editions like Build Tools / Enterprise / Community etc.) can be installed side-by-side, which is why you won't find these MSBuild assemblies in the GAC.
I was having this issue building a SQL Server project on a CI/CD pipeline. None of the pre-built build tasks on Azure DevOps would work for me. I solved this by avoiding to add a SQL Server project to the solution.
I achieved this by using an MSBuild SDK, capable of producing a SQL Server Data-Tier Application package (.dacpac) from the set of SQL scripts. By adding this second project to the solution, I managed to continue taking advantage of linking the project to a live database through SQL Server Object Explorer on Visual Studio. I gave a more detailed explanation in this answer.

Visual Studio Build Tools 2017 for Office VSTO

I have installed the vs build tools 2017 on a build server.
When I try to build with /t:Publish /p:PublishDir="pub/"
I get
_DeploymentUnpublishable:
Skipping unpublishable project.
Is there a way to fix this or do i need to install the full VS with office developer tools?
Is there a way to fix this or do i need to install the full VS with office developer tools?
I got the same error with your MSBuild arguments on command line:
You need to configure the MSBuild command line on your build server with those two additional arguments: /p:DeployOnBuild=true and /p:PublishProfile=your_publish_profile.pubxml instead of /t:Publish /p:PublishDir="pub/.
So the MSBuild command line should be:
msbuild.exe "YourProjectName.csproj" /p:DeployOnBuild=true /p:PublishProfile=PublishProfileName.pubxml
Of course, you need create the publish profile .pubxml, You don't need to specified path to publish_profile.pubxml as long as it's under the PublishProfiles directory with your project file.
Update for Ant`s comment:
Since your project type is a "Excel 2013 and 2016 VSTO Add-in", not "Excel Web Add-in", we should use ClickOnce publish method to deploy project. I have created a sample demo with VS 2017 and build it with TFS 2017. You can check if it helps:
Create a Excel 2013 and 2016 VSTO Add-in project with VS 2017.
Publish this project from VS manually, then ProjectName_TemporaryKey.pfx file will be generated. Check this project include .pfx file into TFS.
Edit build definition with MSBuild task. and add /t:Publish /p:PublishDir="pub/" to MSBuild argument:
Save and build this project.
According to the build log, this project publish successfully:
Note: Add the .pfx file to your build server and my build server installed VS 2017, but AFAIK, you do not need to install the entire VS, you should install the workload Office/SharePoint development:

Trying to build nuget package with VS 2017 Team Explorer installed

I installed the VS 2017 TeamExplorer which added a separate VS 2017 install folder. Now when I try to build a nuget package, I get an error saying
The imported project "C:\Program Files (x86)\Microsoft Visual
Studio\2017\TeamExplorer\MSBuild\15.0\bin\Roslyn\Microsoft.CSharp.Core.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk. C:\Program Files
(x86)\Microsoft Visual
Studio\2017\TeamExplorer\MSBuild\15.0\bin\Microsoft.CSha
rp.CurrentVersion.targets
So it appears now it is trying to use MSBuild from the TeamExplorer install path instead of the Enterprise path.
MSBuild auto-detection: using msbuild version '15.3.409.57025' from
'C:\Program Files (x86)\Microsoft Visual
Studio\2017\TeamExplorer\MSBuild\15.0\bin'.
Is there a way to make the original path (Enterprise) the default for MSBuild?
UPDATE
I will mark this as the answer until a better solution comes along!
This isn't a GOOD answer but I uninstalled the VS 2017 Team Explorer and it now works properly. I still would like to know how we can control this.

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 Build Tools missing DNX

I've installed Visual Studio 2015 Build Tools onto our TeamCity server but the DNX folder is missing from within its installation root.
MSBuild 14 won't build an xproj because it imports Microsoft.DNX.targets
I've installed the latest DNX via the DNVM but it didn't create the DNX folder I was hoping it would.
The folder is obviously there on my dev box with VS2015 installed. I guess I could install the VS Community Edition, but why would the build tools be missing a crucial component??
Right now the DNX MSBuild targets are only installed with Visual Studio 2015 (specifically the Web Development Tools component).
https://github.com/aspnet/dnx/issues/2207#issuecomment-120076364
So it looks like I'll have to install Visual Studio 2015 Community Edition on the build server.
People are saying I should be using dnu from the command line, but the issue is that I need to make an MSDeploy package, and AFAIK, only MSBuild can do this.
Looks like I need to read this.
http://docs.asp.net/en/latest/publishing/iis.html