简体   繁体   中英

Where is PackageReference located in console application C#

I have came across this line of code in a code and its quite confusing

One of my client send a dependancy file that contains

<ItemGroup>
    <PackageReference Include="xyzrefrence" Version="1.3.0" />

and said it is console application. I created same kind of application but within packages.config I found this thing

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="xyz" version="1.7.7.7" targetFramework="net452" />

My question is that where the dependacy file located with the client setting(First settings)

The reference ( <ItemGroup><PackageReference..... ) to the dependency can be found by editing the Visual Studio project file. *.csproj

The dependency file itself can be found in your project's /bin/debug or /bin/release folders.

Where is PackageReference located in console application C#

There are two nuget mamangement format( Packages.config and PackageReference ) to intall nuget packages.

In fact , PackageReference is a new nuget management format for new sdk projects( net standard and net core ) since VS2017 while Packages.config is an old tranitional nuget management format for net framework projects.

However , you should note that for traditional framework projects, Microsoft made a concession to use the new SDK's pacakgeReference format, but there are still various compatibility issues.--------( net frameowork projects can use both of them while net core / net standard projects can only use PackageReference ).

If you use a net framework project, you can change these two format before you install nuget packages at the beginning by Tools --> Options --> NuGet Package Manager --> General --> Package Management .

在此处输入图片说明

And you should specifiy this format before you install the first nuget package at the beginning and when you specify this format, the nugets you install later will use this method by default and cannot be changed.

My question is that where the dependacy file located with the client setting(First settings)

1) If you use a net framework console project with PackageReference , l am afraid that you cannnot see the depenencies of the nuget. The old sdk projects with PackageReference does not support showing the depenencies of the nuget packages due to several compatibility issues.

2) If you use a net core console project, you can see the dependencies in the Solution Explorer and the latest new sdk projects does support this. It has a new behavior that you can see every nuget package's depenencies under its branch in the Soluton Explorer.

在此处输入图片说明

Besides , since you use a framework project with packages.config , you can only see all of them(the premise is that this nuget package has dependencies.) in the packages.config file or in the xxxx.csproj file but it cannot subdivide dependencies for every nuget package.

In additon , if you still want to show the depenencies of the net framework projects with PackageReference, l suggest you could post a feature request in ourUser Voice forum(DC) - suggest a feature to get Micorosft's attention.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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