Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build succeeded with projects Ctrl + Shift + B that MSBuild can't build

Tags:

c#

msbuild

tfs

Does anyone know where I can take a look at my project if after I make a build with MSBuild through MSBuild console I get this warning:

MSB4078: The project file 'MyProject.csproj' is not supported by MSBuild and cannot be built?

My project is running with Target Framework .Net Core 2.0. The MSBuild version I am using is 14.0.25420.1

enter image description here

This is the cs.proj

enter image description here

like image 589
Zinov Avatar asked Jan 19 '18 18:01

Zinov


2 Answers

You are using the new csproj file format (see Project sdk=...)

You will need to use MSBuild 15 in order for it to build. You have two options:

1) Download Build Tools for Visual Studio 2017 and install. Then the path will be:

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin

2) If you have VS installed, the path will be:

C:\Program Files (x86)\Microsoft Visual Studio\2017\<VS Version>\MSBuild\15.0\Bin

Using MSBuild 15 should fix the error.

like image 149
SwDevMan81 Avatar answered Oct 11 '22 17:10

SwDevMan81


I suggest to use MSBuild in more reliable way.

  1. Download Build Tools for Visual Studio 2017 from Visual Studio Downloads page, it includes latest MSBuild 15.* (direct link).

    Command-line arguments documented here: Use command-line parameters to install Visual Studio 2017.

    All workloads and components are listed here: Visual Studio Build Tools 2017 component directory.

  2. Use PowerShell module VSSetup to find MSBuild. Download it or install from here: Github: Microsoft/Visual Studio Setup PowerShell Module

Find MS Build

Import-Module $PSScriptRoot\VSSetup\VSSetup.psd1

$msBuildPath = (Get-VSSetupInstance | Select-VSSetupInstance -Version 15.0 -Product Microsoft.VisualStudio.Product.BuildTools).InstallationPath

if ([System.IntPtr]::Size -eq 8)
{
    $global:msbuildPath = Join-Path $msBuildPath 'MSBuild\15.0\Bin\amd64'
}
else
{
    $global:msbuildPath = Join-Path $msBuildPath 'MSBuild\15.0\Bin'
}

Write-Output "Using MSBuild from $global:msbuildPath"
Write-Output "MSBuild /version"

$msbuild = Join-Path $global:msbuildPath msbuild

& $msbuild /version
like image 41
Vlad DX Avatar answered Oct 11 '22 17:10

Vlad DX