VS 2017 版本 15.5.1 - System.Net.Http 未解决的项目引用 [英] VS 2017 Release 15.5.1 - Project Reference to System.Net.Http Unresolved

查看:37
本文介绍了VS 2017 版本 15.5.1 - System.Net.Http 未解决的项目引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您在下面看到的代码并不完美,但它是我帮助维护的代码状态的实际表示.我的问题不是关于构建此代码的正确方法,而是为什么此代码在 VS 2017 的早期版本(例如 2 周前)中有效,而现在却没有.我正在尝试确定此问题是否是 VS 的错误,需要在我们的代码库中解决,或者是否需要在我们的代码库中解决.

I understand the code that you see below is not perfect, but it is the actual representation of the state of code I am helping maintain. My question isn't in regards to the right way to structure this code, it is why did this code work in previous versions of VS 2017 (like 2 weeks ago) and why it does not now. I am trying to determine if this issue is a bug with VS that will be addressed OR if this needs to be addressed in our code base.

该项目在 VS 2017 版本 15.4.5(以及 VS 2015)中有正确的引用,但在 VS 2017 15.5.1 或 15.5.2 中没有.

This project has proper references in VS 2017 release 15.4.5 (as well as VS 2015), but not in VS 2017 15.5.1 or 15.5.2.

这个显示问题的示例解决方案只有一个项目.下面是项目文件:

This sample solution to show the issue has only one project. Below is the project file:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <OldToolsVersion>3.5</OldToolsVersion>
    <IsWebBootstrapper>true</IsWebBootstrapper>
    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
    <Install>true</Install>
    <InstallFrom>Web</InstallFrom>
    <UpdateEnabled>true</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateInterval>7</UpdateInterval>
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
    <UpdatePeriodically>false</UpdatePeriodically>
    <UpdateRequired>false</UpdateRequired>
    <MapFileExtensions>true</MapFileExtensions>
    <ApplicationRevision>0</ApplicationRevision>
    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
    <UseApplicationTrust>false</UseApplicationTrust>
    <BootstrapperEnabled>true</BootstrapperEnabled>
    <ProjectGuid>{B3FE0477-3F25-4D78-9618-2DD0889C0194}</ProjectGuid>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <ItemGroup>
    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
      <Visible>False</Visible>
      <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Class1.cs" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System.Net.Http">
      <HintPath>..\..\packages\System.Net.Http.2.0.20126.16343\lib\net40\System.Net.Http.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Net.Http.WebRequest">
      <HintPath>..\..\packages\System.Net.Http.2.0.20126.16343\lib\net40\System.Net.Http.WebRequest.dll</HintPath>
      <Private>True</Private>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <None Include="packages.config" />
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

该项目只包含一个类:

using System.Net.Http;

namespace Reference_Issue
{
    public class Class1
    {
        private HttpRequestMessage test;
        public Class1()
        {
            test = new HttpRequestMessage();
        }
    }
}

和 package.config

and the package.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="System.Net.Http" version="2.0.20126.16343" targetFramework="net45" />
</packages>

推荐答案

我相信这对应于 15.5 中的这个错误:https://developercommunity.visualstudio.com/content/problem/161697/vs2017-v155-ignoring-nuget-package-microsoftnethtt.html

I believe this corresponds to this bug in 15.5: https://developercommunity.visualstudio.com/content/problem/161697/vs2017-v155-ignoring-nuget-package-microsoftnethtt.html

这篇关于VS 2017 版本 15.5.1 - System.Net.Http 未解决的项目引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆