I'm trying to upgrade the following template project to ASP.NET Core 1.1: https://github.com/wilanbigay/aspnet-core-aurelia-typescript-starter
After running dotnet migrate the project.json file has been dropped in favour of the new csproj file.
Using Visual Studio Code and the Nuget4Code extension I've upgraded all components to ASP.NET Core 1.1.
The CsProj now contains entries like so:
<ItemGroup> <PackageReference Include="Microsoft.NET.Sdk"> <Version>1.0.0-alpha-20161104-2</Version> <PrivateAssets>All</PrivateAssets> </PackageReference> <PackageReference Include="Microsoft.NET.Sdk.Web"> <Version>1.0.0-alpha-20161104-2</Version> <PrivateAssets>All</PrivateAssets> </PackageReference> <PackageReference Include="Microsoft.NETCore.App"> <Version>1.1.0</Version> </PackageReference> <PackageReference Include="Microsoft.AspNetCore.Mvc"> <Version>1.1.0</Version> </PackageReference>
However I have compilation issues. It seems the AspNetCore namespace can't be found. I'm getting the error
Error CS0234: The type or namespace name 'AspNetCore' does not exist in the names pace 'Microsoft' (are you missing an assembly reference?)
I'm not sure how I can check references like I used to be able to in Visual Studio in the references section. How can I resolve this?
To fix this error, simply update the example . csproj file to use a previous System. CommandLine version. Note that this package is only used to parse the options for the example.
IWebHostEnvironment Provides information about the web hosting environment an application is running in. belongs to namespace Microsoft.AspNetCore.Hosting. The IWebHostEnvironment interface need to be injected as dependency in the Controller and then later used throughout the Controller.
We just had this issue where visual studio helpfully added a local reference rather than going via nuget
<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>
Removing this and referencing via nuget solved the problem, looks like an issue in Visual Studio 2017.
So I guess I was referencing the dependencies but didn't have them installed for the project.
All I needed to do was run dotnet restore
https://docs.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-restore
As stated in the link above this "Restores the dependencies and tools of a project."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With