Skip to content

Commit

Permalink
Add project2project scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
erdembayar committed Dec 9, 2022
1 parent 58f030a commit d231ef3
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion proposed/2022/PrivateAssetIndepdentFromExcludeAsset.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ We couldn't make this default experience because it'll break customers who rely
<!-- Explain the proposal as if it were already implemented and you're teaching it to another person. -->
<!-- Introduce new concepts, functional designs with real life examples, and low-fidelity mockups or pseudocode to show how this proposal would look. -->
The new ` PrivateAssetIndependent` property only affects pack operation (more specifically nuspec in nupkg file), but doesn't affect restore experience for current project so there would be no change in `project.assets.json` lock file.
Experience for parent consuming project would be affected by which asset from `compile, runtime, contentFiles, build, buildMultitargeting, buildTransitive, analyzers, native` are flowing into them.
Experience for parent consuming project would be affected by which asset from `compile, runtime, contentFiles, build, buildMultitargeting, buildTransitive, analyzers, native` are flowing into them for both `PackageReference` and `ProjectReference` consumptions.

For the following table assume `PrivateAssetIndependent` is set `true` when creating package, iterating possible scenarios (not full list) for consuming parent project.

Expand All @@ -34,6 +34,24 @@ For the following table assume `PrivateAssetIndependent` is set `true` when crea
| build | Enable msbuild imports | Build fails due to property/target value change |
| analyzers | Code analyzers work | n/a |

Here is brief summary for what would change for consuming `parent` project.

Before change for given `asset`:
IncludeAssets|PrivateAssets|Flows transitively
--|--|--
yes|yes|yes
yes|no|no
no|yes|no
no|no|no

After change for given `asset`:
IncludeAssets|PrivateAsset|Flows transitively
--|--|--
yes|yes|yes
yes|no|no
no|yes|yes
no|no|no

#### Examples

##### Case 1 for PackageReference
Expand All @@ -49,6 +67,7 @@ Package reference in csproj file.
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.138-beta" PrivateAssets="none" ExcludeAssets="build" />
</ItemGroup>
```

Before change nuspec file:

Expand Down Expand Up @@ -103,6 +122,38 @@ After change nuspec file:
</dependencies>
```

##### Case for Project to Project reference

Package reference in parent `ClassLibrary1` csproj file.

```.net
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\refissue\refissue.csproj" />
</ItemGroup>
```

```.net
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<VersionSuffix>beta</VersionSuffix>
<PrivateAssetIndependent>True</PrivateAssetIndependent>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.138-beta" PrivateAssets="none" ExcludeAssets="all" />
</ItemGroup>
```

Before change for `Microsoft.Windows.CsWin32.props` file in `build` asset doesn't flow to ClassLibrary1.csproj.nuget.g.props file in obj folder.

After change for `Microsoft.Windows.CsWin32.props` file in `build` asset flow to ClassLibrary1.csproj.nuget.g.props file in obj folder.

### Technical explanation

We already have a [logic](hhttps://github.com/NuGet/NuGet.Client/blob/380415d812681ebf1c8aa0bc21533d4710514fc3/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs#L577-L582) that combines `IncludeAssets/ExcludeAssets` options with `PrivateAssets`, we just change precedence on that logic depending on opt-in property.
Expand Down

0 comments on commit d231ef3

Please sign in to comment.