简体   繁体   English

VS 2017版本15.5.1 - 项目参考System.Net.Http未解决

[英]VS 2017 Release 15.5.1 - Project Reference to System.Net.Http Unresolved

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. 我的问题不是关于构造此代码的正确方法,这就是为什么这段代码在VS 2017的早期版本(如2周前)中工作的原因以及为什么现在没有。 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的错误,如果需要在我们的代码库中解决这个问题。

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. 该项目在VS 2017版本15.4.5(以及VS 2015)中有适当的参考,但在VS 2017 15.5.1或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>

The project only contains one class: 该项目只包含一个类:

using System.Net.Http;

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

and the package.config 和package.config

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM