Visual Studio 2017 MSBuild failed to build Azure F

2019-08-08 08:30发布

问题:

I have created azure functions using Visual Studio 2017(Professional Edition), I can successfully build the azure function within visual studio,

But I have a requirement where I have to build and create package without visual studio 2017, so I have tried to build the azure functions from MSBuild 2017 referring the link : https://blogs.technet.microsoft.com/livedevopsinjapan/2017/09/12/build-and-deploy-azure-functions-without-using-visual-studio-2017/

MSBuild Command :

"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe" "Telemetry.sln" /nologo /nr:false /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="WebApp.zip" /p:DeployIisAppPath="Default Web Site" /t:"Telemetry:Clean;Build";"Telemetry_Test:Clean;Build" /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="15.0"

Executed above command and it failed to build azure functions

C:\..\MyFunctionAppTest>"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe" "MyFunctionAppTest.sln" /nologo /nr:false /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="WebApp.zip" /p:DeployIisAppPath="Default Web Site" /t:"MyFunctionAppTest:Clean;Build" /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="15.0"
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 12/11/2017 6:57:19 AM.
Project "C:\..\MyFunctionAppTest\MyFunctionAppTest.sln" on node 1 (MyFunctionAppTest:Clean;Build target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "release|any cpu".
Project "C:\..\MyFunctionAppTest\MyFunctionAppTest.sln" (1) is building "C:\..\MyFunctionAppTest\MyFunctionAppTes
t\MyFunctionAppTest.csproj" (2) on node 1 (Clean;Build target(s)).
C:\..\MyFunctionAppTest\MyFunctionAppTest\MyFunctionAppTest.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk' spec
ified could not be found.
Done Building Project "C:\..\MyFunctionAppTest\MyFunctionAppTest\MyFunctionAppTest.csproj" (Clean;Build target(s)) -
- FAILED.

Done Building Project "C:\..\MyFunctionAppTest\MyFunctionAppTest.sln" (MyFunctionAppTest:Clean;Build target(s)) -- F
AILED.


Build FAILED.

"C:\..\MyFunctionAppTest\MyFunctionAppTest.sln" (MyFunctionAppTest:Clean;Build target) (1) ->
"C:\..\MyFunctionAppTest\MyFunctionAppTest\MyFunctionAppTest.csproj" (Clean;Build target) (2) ->
  C:\..\MyFunctionAppTest\MyFunctionAppTest\MyFunctionAppTest.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk' sp
ecified could not be found.

回答1:

Make sure to install the .NET Core workload in MS Build installation:

If it doesn't help, check other comments in this issue.