Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binki/nugetrestoredynamicprojectreference
https://github.com/binki/nugetrestoredynamicprojectreference
msbuild nuget
Last synced: 25 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/binki/nugetrestoredynamicprojectreference
- Owner: binki
- License: other
- Created: 2018-09-09T21:31:50.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-23T21:51:35.000Z (over 5 years ago)
- Last Synced: 2024-11-12T05:38:33.833Z (3 months ago)
- Topics: msbuild, nuget
- Language: C#
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Demonstration of how to support `msbuild/r` (msbuild with nuget package restore) when adding `` via targets.
# Use Case
You may want to dynamically calculate which projects to include in your build based on configuration such as licensing.
Thus, you develop an MSBuild target which runs prior to `BeforeResolveReferences` to dynamically scan for and add optional projects by adding ``.
However, you find that these dynamically added `` are ignored by the restore phase of `msbuild/r`.# Implementation
See [Runner/Build/AddDynamicReferences.targets](Runner/Build/AddDynamicReferences.targets).
# Pitfalls
## Visual Studio
Dynamically adding `` is only supported by `msbuild` itself.
Visual Studio manages build dependencies internally and does not provide a reasonable way to recognize dependencies added by targets.
You may choose to instruct Visual Studio to always invoke `msbuild` for builds (is that possible?) or have special logic to write dependencies to files and `` out and touch the project file to force VS users to reload the project when you detect that you are being built in VS.## Private API
This solution relies on a private API.
I have opened https://github.com/NuGet/Home/issues/7288 to inquire about making this a supported scenario or discovering if there might be some other more acceptable mechanism to achieve the same effect.