安装了NuGet包,Visual Studio声称程序集未引用

时间:2017-06-09 14:26:41

标签: asp.net-core visual-studio-2017

你可以看到我通过nuget引用它,但仍在抱怨。这是嵌入式视图组件中的.net 4.6.1框架类库。 我也在使用.net框架的asp.net核心网络应用程序。 我有很多问题试图让剃刀工作,但这是一个新的。 MenuViewPage继承RazorPage并位于另一个程序集中。 我想我应该安装.net core 2和aspnetcore.all;)\

任何人都有任何想法为什么会这样?

Razor error

1 个答案:

答案 0 :(得分:0)

因此,经过几个小时的尝试解决这个问题,我已经找到了解决方案:

创建Web类库时,无论是将其用于应用程序部件还是使用基类创建核心项目我建议您将其从正常的.net类库转换为支持Web的库

要将其转换为Web类库,您需要更改项目以使用以下.csproj,然后确保运行dotnet restore。

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <OutputType>Library</OutputType>
  </PropertyGroup>

  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
    <RuntimeIdentifier>win7-x86</RuntimeIdentifier>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <ApplicationIcon />
    <OutputTypeEx>library</OutputTypeEx>
    <StartupObject />
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DocumentationFile></DocumentationFile>
    <NoWarn>1701;1702;1705;1591</NoWarn>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
    <PackageReference Include="Microsoft.AspNetCore.Session" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Razor">
      <Version>1.1.2</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.AspNetCore.Razor.Runtime">
      <Version>1.1.2</Version>
    </PackageReference>
    <PackageReference Include="System.Net.Http" Version="4.3.2" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
  </ItemGroup>
</Project>

确保您将输出类型设为库。 我遇到了程序集信息文件的问题,它似乎是在构建过程中生成的,所以我通过双击&#34;属性&#34;

注释掉了assembly.info的东西。

我希望将来可以帮助某人。