-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
In project.json, dependencies could be either a project or a package reference. NuGet and compilation would resolve the package vs project based on some conventions (like folder name) and the global.json file. Futhermore, VS would automatically add new projects to the solution explorer when the were discovered.
In MSBuild, there is no equivalent feature. References are either ProjectReference or PackageReference. Swapping a package reference to a project is not always straight forward. In cases where the package is a transitive reference from other PackageReferences, you have to keep the PackageReference and set ExcludeAssets=All in order to avoid conflicts between ProjectReference and PackageReference. (See https://docs.microsoft.com/en-us/nuget/schema/msbuild-targets#replacing-one-library-from-a-restore-graph). It also requires manually adding new projects to the sln file so they appear in VS.
It would be nice to provide a way to resolve PackageReference to projects without requiring changes to csproj.
Some data on this:
- The ASP.NET team frequently needs this as we debug components across multiple solutions. We've attempted to automate this with scripting. (See this script in Kestrel). cc @pakrym
- ASP.NET core benchmark automation also had to implement a way to resolve package references as projects. Implementing this required writing code that hunts for PackageReference and edits the csproj file locally. See Restore source dependencies feature (#185) aspnet/Benchmarks#190 cc @mikeharder
- I've been asked about this several times from non-Microsoft devs
- http://www.natemcmaster.com/blog/2017/01/19/project-json-to-csproj/#comment-3203817959
- http://www.natemcmaster.com/blog/2017/02/01/project-json-to-csproj-part2/#comment-3206867094
- http://www.natemcmaster.com/blog/2017/03/09/vs2015-to-vs2017-upgrade/#comment-3273066914
- Twitter: https://twitter.com/digory/status/846119886426271744
- StackOverflow question: http://stackoverflow.com/questions/42773815/net-core-csproj-global-json-projects-equivalent