Last active
May 8, 2025 21:29
-
-
Save Lordfirespeed/e3988f83f4831282007e0f2bd179b598 to your computer and use it in GitHub Desktop.
Resolve full paths to referenced assemblies by name in MSBuild
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Project> | |
| <Target Name="ResolveAssemblyPaths"> | |
| <ItemGroup> | |
| <IncludeProjectReferencedAssemblyName Include="Serilog.Sinks.BepInEx" /> | |
| <IncludePackageReferencedAssemblyName Include="Serilog" /> | |
| </ItemGroup> | |
| <!-- ProjectReference assemblies --> | |
| <JoinItems | |
| Left="@(ReferencePath)" | |
| LeftKey="FileName" | |
| LeftMetadata="*" | |
| Right="@(IncludeProjectReferencedAssemblyName)" | |
| RightKey="Identity" | |
| ItemSpecToUse="Left" | |
| > | |
| <Output TaskParameter="JoinResult" ItemName="IncludeAssemblyPath" /> | |
| </JoinItems> | |
| <!-- PackageReference assemblies --> | |
| <JoinItems | |
| Left="@(RuntimeCopyLocalItems)" | |
| LeftKey="FileName" | |
| LeftMetadata="*" | |
| Right="@(IncludePackageReferencedAssemblyName)" | |
| RightKey="Identity" | |
| ItemSpecToUse="Left" | |
| > | |
| <Output TaskParameter="JoinResult" ItemName="IncludeAssemblyPath" /> | |
| </JoinItems> | |
| <Message Importance="high" Text="Resolved: @(IncludeAssemblyPath->'"%(Identity)"', '; ')"/> | |
| </Target> | |
| </Project> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This'll only work in
dotnetSDK'sbuildcommand atm, not Visual Studio, since Visual Studio's MSBuild is missing theJoinItemstask