Reputation: 2941
I want to compile a .net project using net core 3, in the hope that it will then run on the latest Ubuntu.
I have downloaded VS2019, and the net core 3 SDK, and enabled previews in Tools/Options/Environment/Preview features.
I created a new project (it defaulted to net core 3.0), added some source files, and tried to build it.
I got these errors:
1>------ Build started: Project: BaseCampApi, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\3.0.100-preview5-011568\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(157,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
1>c:\dev\BaseCampApi\BaseCampApi\BasecampApi.cs(18,17,18,27): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
1>c:\dev\BaseCampApi\BaseCampApi\BasecampApi.cs(303,17,303,49): error CS0246: The type or namespace name 'FileExtensionContentTypeProvider' could not be found (are you missing a using directive or an assembly reference?)
1>Done building project "BaseCampApi.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
What do I do to get it to compile?
Upvotes: 1
Views: 543
Reputation: 5695
Did you restore all dependencies?
Try running dotnet restore
and then dotnet build
if you're using the terminal or just Nuget Restore through VS.
If it doesn't help, you'll have to remove some artifacts from the .csproj
file and restore dependencies after that. Look for something like:
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Mvc.Core">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.core\2.0.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Core.dll</HintPath>
</Reference>
</ItemGroup>
Remove it and reference it anew by restoring with Nuget.
Also, make sure you're actually in an ASP.NET project and not a console one, for example. Your project is called "*Api" which in the general case should mean that it is an ASP.NET project indeed but you never know.
EDIT after comments:
So, it turned out you have a Console application after all and you're referencing packets from ASP.NET. Either create a new ASP.NET Web App and move your code there or include the framework packets(if you need them that much AND if they're actually compatible considering the task in hand). Most probably there should be an alternative ones for console applications, though, so you should use them instead).
Upvotes: 2