I have been asked to submit my issue here by @rainersigwald
Original Tweet: https://twitter.com/gregpakes/status/1122672235439804416
Background
I am porting a tiny WCF application to Asp.Net Core 3.0 Preview 4. After port, it is a a basic Asp.Net Core Web Api with a database project (sqlproj). Here are the issues I encountered:
- None of the happy path templates worked out of the box, due to the fact sqlproj is non-sdk project system. So
dotnet build doesn't work.
- I used the
UseDotNet@2 task to install .net core 3.0 preview. That was fine.
dotnet build would then give me this error:
error MSB4019: The imported project "/opt/hostedtoolcache/dncs/3.0.100-preview4-011223/x64/sdk/3.0.100-preview4-011223/Microsoft/VisualStudio/v11.0/SSDT/Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
- I then realised I had to use msbuild instead. (probably me, but this really wasn't clear to me).
- When I used the MSBuild task or the
Visual Studio Build Task, I would get this error:
Error : Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
and
Error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
- At this point, I got confused about nuget restore. I wasn't sure if I should be using separate nuget task or
dotnet restore. Given I had a sqlproj file, the error messages were confusing. dotnet build would give me this:
error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\MSTest.TestAdapter.2.0.0-beta4\build\net45\MSTest.TestAdapter.props.
- However, when I used a seperate nuget restore (using 5.x), I would get this:
[command]C:\hostedtoolcache\windows\NuGet\5.0.0\x64\nuget.exe sources Add -NonInteractive -Name NuGetOrg -Source https://api.nuget.org/v3/index.json -ConfigFile d:\a\1\Nuget\tempNuGet_24152.config
Package source with Name: NuGetOrg added successfully.
[command]C:\hostedtoolcache\windows\NuGet\5.0.0\x64\nuget.exe restore d:\a\1\s\iSAMS.Mobile.sln -Verbosity Detailed -NonInteractive -ConfigFile d:\a\1\Nuget\tempNuGet_24152.config
d:\a\1\s\iSAMS.Mobile.Api\iSAMS.Mobile.Api.csproj : error : Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
NuGet Version: 5.0.0.5923
d:\a\1\s\iSAMS.Mobile.Api\iSAMS.Mobile.Api.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
MSBuild auto-detection: using msbuild version '16.0.461.62831' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
d:\a\1\s\iSAMS.Mobile.Api.Tests\iSAMS.Mobile.Api.Tests.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
MSBuild P2P timeout [ms]: 120000
d:\a\1\s\iSAMS.Mobile.Api.IntegrationTests\iSAMS.Mobile.Api.IntegrationTests.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin\msbuild.exe "C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\o513ajfj.g4g.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets="C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\vhcrbbfv.v00.nugetrestore.targets" /p:RestoreUseCustomAfterTargets="True" /p:RestoreTaskAssemblyFile="C:\hostedtoolcache\windows\NuGet\5.0.0\x64\nuget.exe" /p:RestoreSolutionDirectory="d:\a\1\s\\" /p:RestoreConfigFile="d:\a\1\Nuget\tempNuGet_24152.config" /p:SolutionDir="d:\a\1\s\\" /p:SolutionName="iSAMS.Mobile"
d:\a\1\s\iSAMS.Mobile.Legacy\iSAMS.Mobile.Legacy.csproj : error : Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
NuGet.CommandLine.ExitCodeException: Exception of type 'NuGet.CommandLine.ExitCodeException' was thrown.
d:\a\1\s\iSAMS.Mobile.Legacy\iSAMS.Mobile.Legacy.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.
at NuGet.CommandLine.MsBuildUtility.<GetProjectReferencesAsync>d__6.MoveNext()
- I eventually settled on using
dotnet restore as the sqlproj has no dependencies.
- Now back to the
Error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. error.
- I solved this by setting the Msbuild architecture to
x64. Now the error message was:
Error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.0. Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0.
- I fixed this by specifying a global.json. From what I was reading, I really had no idea whether global.json was required. It works in VS without it, so I am still confused as to why i need it in the build.
Apologies for the long rambling post. I'm sure a lot of this is due to my unfamiliarity with the new bits, but I was asked to post... so I hope it helps.
I have been asked to submit my issue here by @rainersigwald
Original Tweet: https://twitter.com/gregpakes/status/1122672235439804416
Background
I am porting a tiny WCF application to Asp.Net Core 3.0 Preview 4. After port, it is a a basic Asp.Net Core Web Api with a database project (sqlproj). Here are the issues I encountered:
dotnet builddoesn't work.UseDotNet@2task to install .net core 3.0 preview. That was fine.dotnet buildwould then give me this error:error MSB4019: The imported project "/opt/hostedtoolcache/dncs/3.0.100-preview4-011223/x64/sdk/3.0.100-preview4-011223/Microsoft/VisualStudio/v11.0/SSDT/Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.Visual Studio Build Task, I would get this error:and
dotnet restore. Given I had a sqlproj file, the error messages were confusing.dotnet buildwould give me this:error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\MSTest.TestAdapter.2.0.0-beta4\build\net45\MSTest.TestAdapter.props.dotnet restoreas the sqlproj has no dependencies.Error MSB4236: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.error.x64. Now the error message was:Apologies for the long rambling post. I'm sure a lot of this is due to my unfamiliarity with the new bits, but I was asked to post... so I hope it helps.