Properties delivered in a NuGet package referenced via packages.config are not reevaluated after restore
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 133
Description
This issue arises when trying to deliver MSBuild targets/properties in a NuGet package (which I'll call the *targets package*). The targets package uses the new csproj format and is multi-targeted. In my case, I am targeting `netstandard2.0;net461`.
The targets package delivers a `props` file which contains the following property:
```
example property
```
and a `targets` file which contains the following target:
```
```
When the targets package is packed to a NuGet package and then installed into a project using a 'classic' csproj (which I'll call the host package), these lines are added - as expected - to the csproj:
```
[...]
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
```
However, when building the host package, the properties are not evaluated. The build prints the incorrect output `The example property is `.
### Steps to reproduce
* Clone https://github.com/rossng/PropsBugDemonstrator
* Open the solution in Visual Studio (tested with 2019/16.0.0 preview 3.0)
* Build `PropsProject` to produce the targets package `PropsProject\bin\Debug\PropsProject.1.0.0.nupkg`
* Copy the NuGet package to your local repository
* Restore packages for the `PropsBugDemonstrator` project
* Rebuild the `PropsBugDemonstrator` project
### Expected behaviour
During the build, the `TestTarget` defined in the targets package is executed and prints `The example property is example property`.
### Actual behaviour
During the build, the `TestTarget` defined in the targets package is executed and prints `The example property is `.
Log excerpt:
```
1>Target "TestTarget: (TargetId:3)" in file "C:\Users\Ross Gardiner\Documents\Projects\PropsBugDemonstrator\packages\PropsProject.1.0.0\build\PropsProject.targets" from project "C:\Users\Ross Gardiner\Documents\Projects\PropsBugDemonstrator\PropsBugDemonstrator\PropsBugDemonstrator.csproj" (target "BeforeBuild" depends on it):
1>Task "Message" (TaskId:4)
1> Task Parameter:Text=The example property is (TaskId:4)
1> Task Parameter:Importance=High (TaskId:4)
1> The example property is (TaskId:4)
1>Done executing task "Message". (TaskId:4)
```
### Other notes
If you can't reproduce the issue, try deleting all `packages`, `bin` and `obj` folders before building.
The issue does not arise if using the new csproj format for `PropsBugDemonstrator`. In the 'real' instance of this bug I do not currently have the option to switch to the new format.
I am unable to reproduce the issue using the command line interface to MSBuild. Steps to try this are (starting from repository root):
```
cd PropsBugDemonstrator
nuget restore -SolutionDirectory ..
msbuild PropsBugDemonstrator.csproj
```
### Environment data
`msbuild /version` output:
```
Microsoft (R) Build Engine version 16.0.360-preview+g9781d96883 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
16.0.360.33175
```
and
```
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
15.9.21.664
```
OS info:
Windows 10 Pro for Workstations 1809, 17763.316
If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):
* Visual Studio 16.0.0 Preview 3.0
* Visual Studio 15.9.7
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.