Skip to content

Commit b963af1

Browse files
committed
Fix nugetize tool for solutions that use project dependencies
Project dependencies is a mechanism to affect the build order in a solution without adding project references. See https://www.cazzulino.com/project-dependencies-as-project-references.html. In this scenario, MSBuild will emit a .metaproj for the solution and *also* a .metaproj for each project that declares such dependencies, which in turn uses project references for the dependencies *and* the original project. This generated .metaproj, obviously, won't have any of the standard targets, not even GetTargetPath, which means we won't be able to even determine if the project is nugetized or not. This used to cause the nugetize tool to refuse to process the other projects in a solution. This change removes such meta projects from the solution so that the other projects can still work. Note that this may result in missing (packable) projects, but the benefit is that you get *some* rendering at least. You can always run nugetize passing the missing projects' contents, but the current experience is clearly far worse than that.
1 parent d8379a2 commit b963af1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/dotnet-nugetize/after.sln.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Target Name="RemoveNonNuGetized" BeforeTargets="GetPackageContents">
4+
<ItemGroup>
5+
<ProjectReference Remove="@(ProjectReference)" Condition="%(Extension) == '.metaproj'" />
6+
</ItemGroup>
7+
48
<MSBuild Properties="BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)"
59
BuildInParallel="True"
610
SkipNonexistentProjects="true"

0 commit comments

Comments
 (0)