Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法还原framework 4.7.2中的nuget包_C#_Visual Studio_Nuget_Visual Studio 2019_Nuget Package Restore - Fatal编程技术网

C# 无法还原framework 4.7.2中的nuget包

C# 无法还原framework 4.7.2中的nuget包,c#,visual-studio,nuget,visual-studio-2019,nuget-package-restore,C#,Visual Studio,Nuget,Visual Studio 2019,Nuget Package Restore,我有一个WPF项目。它有三个用.NETFramework 4.7.2编写的库。我正在尝试还原此解决方案的nuget软件包,但无法 当我右键单击sln文件时,然后选择Restore numget Packages一切似乎都正常: 但在我运行程序后,它仍然缺少所有引用: 在每个csprojpackagaes.config文件中都存在。例如: <?xml version="1.0" encoding="utf-8"?> <packages> <package i

我有一个WPF项目。它有三个用.NETFramework 4.7.2编写的库。我正在尝试还原此解决方案的nuget软件包,但无法

当我右键单击
sln
文件时,然后选择
Restore numget Packages
一切似乎都正常:

但在我运行程序后,它仍然缺少所有引用:

在每个
csproj
packagaes.config
文件中都存在。例如:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Autofac" version="5.0.0" targetFramework="net472" />
  <package id="Caliburn.Micro" version="4.0.62-alpha" targetFramework="net472" />
  <package id="Caliburn.Micro.Core" version="4.0.62-alpha" targetFramework="net472" />
  <package id="LiveCharts" version="0.9.7" targetFramework="net472" />
  <package id="LiveCharts.Wpf" version="0.9.7" targetFramework="net472" />
  <package id="MaterialDesignColors" version="1.2.0" targetFramework="net472" />
  <package id="MaterialDesignExtensions" version="2.7.0" targetFramework="net472" />
  <package id="MaterialDesignThemes" version="2.6.0" targetFramework="net472" />
  <package id="Microsoft.Bcl.AsyncInterfaces" version="1.1.0" targetFramework="net472" />
  <package id="Microsoft.Xaml.Behaviors.Wpf" version="1.0.1" targetFramework="net472" />
  <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" />
  <package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net472" />
</packages>

有两种方法可以管理nuget包:和

根据您的图片,我们可以看到您在项目中使用了这两种格式,这是导致未知恢复问题的原因

(黄色表示Packages.config,蓝色表示packagesreference格式)

我们不应该在一个项目中同时使用这两种格式,因此您的问题的解决方法是强制您的项目只使用一种格式。由于您的三个项目都使用PACKAG.CONFIG,您可以考虑删除项目文件中的<代码> PackageReference < /代码>定义。 解决方法:


编辑项目文件并删除定义,如
xxx
PackageReference
(如果存在)。

有两种方法可以管理nuget软件包:和

根据您的图片,我们可以看到您在项目中使用了这两种格式,这是导致未知恢复问题的原因

(黄色表示Packages.config,蓝色表示packagesreference格式)

我们不应该在一个项目中同时使用这两种格式,因此您的问题的解决方法是强制您的项目只使用一种格式。由于您的三个项目都使用PACKAG.CONFIG,您可以考虑删除项目文件中的<代码> PackageReference < /代码>定义。 解决方法:


编辑项目文件并删除定义,如
xxx
PackageReference
(如果存在)。

我假设在同一项目中同时使用
packages.config
PackageReference
时会出现此问题,这会扰乱恢复过程。若要解决此问题,只需编辑项目文件以仅使用一种格式。嗨,朋友,此问题有更新吗?也许你可以尝试删除解决方案目录中的.vs文件夹,如果该文件夹仍然存在,请重新加载该项目。@LanceLi MSFT感谢你的关注,我还没有检查它,因为这是我的个人项目,我现在正在做其他事情,但我会很快返回,如果你的答案有效,我会将你的答案标记为goof one(我已经投了高分)当然,如果有任何更新,请随时告诉我。在我看来,当一个旧项目的设置混乱时,另一个方向是创建一个新项目并将源文件移到那里。我记得,我只是没有太多时间来研究这个问题。我假设在同一个项目中同时使用
packages.config
packagesreference
时会出现这个问题,这会打乱恢复过程。若要解决此问题,只需编辑项目文件以仅使用一种格式。嗨,朋友,此问题有更新吗?也许你可以尝试删除解决方案目录中的.vs文件夹,如果该文件夹仍然存在,请重新加载该项目。@LanceLi MSFT感谢你的关注,我还没有检查它,因为这是我的个人项目,我现在正在做其他事情,但我会很快返回,如果你的答案有效,我会将你的答案标记为goof one(我已经投了高分)当然,如果有任何更新,请随时告诉我。在我看来,当一个旧项目的设置混乱时,另一个方向是创建一个新项目并将源文件移到那里。我记得,我只是没有太多时间来研究这个问题谢谢!我会在几小时内检查你的答案。我从
.csproj
中删除了
pakcages.confid
,删除了
Include…
,但它仍然没有还原nugets。我用我的示例csprojA编辑了我的答案。临时解决方法是手动下载nuget.exe,将其添加到系统路径变量中,并与packages.config文件一起使用以恢复包。这不是一个好主意,但对于临时使用,您可以尝试一下。在回答上述问题后,您对问题为何仍然存在感到困惑,如果您现在在当前项目中使用新软件包,请检查哪种格式!我想知道VS IDE现在如何识别您的项目、Packages.config或PackageReference?谢谢!我会在几小时内检查你的答案。我从
.csproj
中删除了
pakcages.confid
,删除了
Include…
,但它仍然没有还原nugets。我用我的示例csprojA编辑了我的答案。临时解决方法是手动下载nuget.exe,将其添加到系统路径变量中,并与packages.config文件一起使用以恢复包。这不是一个好主意,但对于临时使用,您可以尝试一下。在回答上述问题后,您对问题为何仍然存在感到困惑,如果您现在在当前项目中使用新软件包,请检查哪种格式!我想知道VS IDE现在如何识别您的项目、Packages.config或PackageReference?
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{07453180-4038-457C-81BB-7017A2890660}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <RootNamespace>Thinning.UI</RootNamespace>
    <AssemblyName>Thinning.UI</AssemblyName>
    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <WarningLevel>4</WarningLevel>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <Deterministic>true</Deterministic>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Autofac, Version=4.9.4.0, Culture=neutral, PublicKeyToken=17863af14b0044da" />
    <Reference Include="Caliburn.Micro.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Caliburn.Micro.Core.4.0.62-alpha\lib\net45\Caliburn.Micro.Core.dll</HintPath>
    </Reference>
    <Reference Include="Caliburn.Micro.Platform, Version=4.0.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Caliburn.Micro.4.0.62-alpha\lib\net45\Caliburn.Micro.Platform.dll</HintPath>
    </Reference>
    <Reference Include="LiveCharts, Version=0.9.7.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
      <HintPath>..\..\packages\LiveCharts.0.9.7\lib\net45\LiveCharts.dll</HintPath>
    </Reference>
    <Reference Include="LiveCharts.Wpf, Version=0.9.7.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
      <HintPath>..\..\packages\LiveCharts.Wpf.0.9.7\lib\net45\LiveCharts.Wpf.dll</HintPath>
    </Reference>
    <Reference Include="MaterialDesignColors, Version=1.2.0.325, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\..\packages\MaterialDesignColors.1.2.0\lib\net45\MaterialDesignColors.dll</HintPath>
    </Reference>
    <Reference Include="MaterialDesignExtensions, Version=2.7.0.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\..\packages\MaterialDesignExtensions.2.7.0\lib\net45\MaterialDesignExtensions.dll</HintPath>
    </Reference>
    <Reference Include="MaterialDesignThemes.Wpf, Version=2.6.0.325, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\..\packages\MaterialDesignThemes.2.6.0\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Xaml.Behaviors, Version=1.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Microsoft.Xaml.Behaviors.Wpf.1.0.1\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Drawing.Design" />
    <Reference Include="System.Xml" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xaml">
      <RequiredTargetFramework>4.0</RequiredTargetFramework>
    </Reference>
    <Reference Include="WindowsBase" />
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
  </ItemGroup>
  <ItemGroup>
    <ApplicationDefinition Include="App.xaml">
      <Generator>MSBuild:Compile</Generator>
      <SubType>Designer</SubType>
    </ApplicationDefinition>
    <Compile Include="App.xaml.cs">
      <DependentUpon>App.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="Helpers\AlgorithmTest.cs" />
    <Compile Include="Helpers\CardContent.cs" />
    <Compile Include="Helpers\Extensions\SimpleContainerExtension.cs" />
    <Compile Include="Helpers\FileDialog.cs" />
    <Compile Include="Helpers\Hardware.cs" />
    <Compile Include="Helpers\ImageLabelModel.cs" />
    <Compile Include="Helpers\Interfaces\IAlgorithmTest.cs" />
    <Compile Include="Helpers\Interfaces\ICardContent.cs" />
    <Compile Include="Helpers\Interfaces\IFileDialog.cs" />
    <Compile Include="Helpers\Interfaces\IHardware.cs" />
    <Compile Include="Helpers\Interfaces\IMainWindowViewModelHelper.cs" />
    <Compile Include="Helpers\Interfaces\IPerformanceChartViewModelHelper.cs" />
    <Compile Include="Helpers\Interfaces\IViewModel.cs" />
    <Compile Include="Helpers\MainWindowViewModelHelper.cs" />
    <Compile Include="Helpers\PerformanceChartViewModelHelper.cs" />
    <Compile Include="ViewModels\MainWindowViewModel.cs" />
    <Compile Include="ViewModels\PerformanceChartViewModel.cs" />
    <Compile Include="ViewModels\ProgressViewModel.cs" />
    <Compile Include="Views\ViewBoxTracking.cs" />
    <Compile Include="Views\MainWindowView.xaml.cs">
      <DependentUpon>MainWindowView.xaml</DependentUpon>
    </Compile>
    <Compile Include="Views\PerformanceChartView.xaml.cs">
      <DependentUpon>PerformanceChartView.xaml</DependentUpon>
    </Compile>
    <Compile Include="Views\ProgressView.xaml.cs">
      <DependentUpon>ProgressView.xaml</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Bootstrapper.cs" />
    <Compile Include="Properties\AssemblyInfo.cs">
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <Compile Include="Properties\Settings.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    <AdditionalFiles Include="..\..\Settings.stylecop">
      <Link>Settings.stylecop</Link>
    </AdditionalFiles>
    <None Include="packages.config" />
    <None Include="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Thinning.Algorithm\Thinning.Algorithm.csproj">
      <Project>{9bfb384e-ca70-407a-9e0e-b9ac235ed7d6}</Project>
      <Name>Thinning.Algorithm</Name>
    </ProjectReference>
    <ProjectReference Include="..\Thinning.Infrastructure\Thinning.Infrastructure.csproj">
      <Project>{19B5AECE-CCE3-4312-AB19-D190AF1A1441}</Project>
      <Name>Thinning.Infrastructure</Name>
    </ProjectReference>
  </ItemGroup>
  <ItemGroup>
    <Page Include="Views\MainWindowView.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:Compile</Generator>
    </Page>
    <Page Include="Views\PerformanceChartView.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:Compile</Generator>
    </Page>
    <Page Include="Views\ProgressView.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:Compile</Generator>
    </Page>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>