Project-system: Improve PackageReference support in old project system

Created on 5 May 2017  路  20Comments  路  Source: dotnet/project-system

Currently the APIs for accessing PackageReference information (that is, the VSProject4 and PackageReferences interfaces) operate more-or-less right on top of the project file's XML. This is limiting in that the PackageReference elements will not have been evaluated; for example, if the Version metadata refers to a property such as $(MyCommonVersion) then what a consumer of these interfaces will see is the literal string "$(MyCommonVersion)" rather than the evaluated value.

We should update these interfaces to work on the evaluated data instead.

Bug Feature-NuGet Legacy Resolution-Fixed

Most helpful comment

We (NuGet team) have been receiving multiple customers (internal Microsoft and external) requests to make this work.

We also want the ecosystem to move forward to start using PackageReference and this seems to be a blocker.

In addition, we are moving towards enabling credential provider support cross plat with dotnet.exe and msbuild.exe and these tools work with PackageReference. Our story will be broken without the variable replacement support.

Is it too late to take this in for 15.6?

All 20 comments

Note the title of this issue says "old" project system, but this is happening with the new .NET SDK project system.

@AArnott What do you mean? We use the evaluated value in the new project system.

I have solution of only new project system projects, and yet NuGet/Home#5295 (which was closed as a dupe of this one) occurs in these solutions.

Can you give me a repro? Make note that @onovotny's repro has a extraneous single quotes around the value.

This works fine:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <GiveMeAVersion>9.0.1</GiveMeAVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="$(GiveMeAVersion)" />
  </ItemGroup>
</Project>

Try moving the ref to directory.build.props. Restore is fine, but every time you build in VS or run tests, the error appears in the output window.

I can still not repro this - I pulled it out into Directory.Build.props, installed xunit, ran tests with zero issue. In the new project system we read all package references using evaluation, so something else must be involved.

Given this is tracking legacy project system support, can you file a new bug with a repro?

I'll find or recreate a repro to share in the next day or two.

Doesn't meet the bar for 15.5; moving out.

OK, at least with my most recent repro, I see that it disappears when I remove the VSIX project from the solution, so it does indeed seem to be an issue with the old project system.

BTW, this blocks running unit tests in affected solutions. It also causes the Solution Restore command to report failure and packages to not be restored.

My team is encountering this issue with the latest version of VS 2017. Due to some of our legacy dependencies, we are unable to migrate our csproj files to use the new .NET SDK format, which I understand doesn't have this issue.

Can we expect a fix for this issue to make it out in 15.6?

Any idea when this is expected to be fixed? (date?)

We do not have an ETA at this time.

Can you please prioritize this. kind of annoying defect.

This error particularly affects VSTS users using authenticated feeds.
Since the (authenticated) IDE restore broken, the only way to restore private packages is to go to a directory that contains CredentialProvider.VSS.exe, and use nuget there, passing in path to my project. This slows down our team's workflow.

We (NuGet team) have been receiving multiple customers (internal Microsoft and external) requests to make this work.

We also want the ecosystem to move forward to start using PackageReference and this seems to be a blocker.

In addition, we are moving towards enabling credential provider support cross plat with dotnet.exe and msbuild.exe and these tools work with PackageReference. Our story will be broken without the variable replacement support.

Is it too late to take this in for 15.6?

Fixed in 15.9.

@tmeschter Using 15.9-preview3, this still happens to me. You can repro by cloning the PowerShell repo here and adding the hosting.csproj to PowerShell.sln. I have done this in my branch here so that you can just repro as follows (in PowerShell):

git clone https://github.com/bergmeister/PowerShell.git PowerShell_bergmeister
cd .\PowerShell_bergmeister
git checkout NuGetBug
Invoke-Item .\PowerShell.sln
# Observe error when building hosting.tests project

NB. I am using the latest .Net SDK v 2.1.402, OS is Windows 10 1809

@bergmeister This bug concerns missing functionality in VS when working with _non_-SDK-based projects. If you're seeing errors while building or when using SDK-based projects (and it looks to me like you are) then that is a separate issue.

Was this page helpful?
0 / 5 - 0 ratings