Skip to content

Instantly share code, notes, and snippets.

@Lordfirespeed
Last active May 8, 2025 21:29
Show Gist options
  • Select an option

  • Save Lordfirespeed/e3988f83f4831282007e0f2bd179b598 to your computer and use it in GitHub Desktop.

Select an option

Save Lordfirespeed/e3988f83f4831282007e0f2bd179b598 to your computer and use it in GitHub Desktop.
Resolve full paths to referenced assemblies by name in MSBuild
<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->'&quot;%(Identity)&quot;', ';&#10;')"/>
</Target>
</Project>
@Lordfirespeed
Copy link
Author

This'll only work in dotnet SDK's build command atm, not Visual Studio, since Visual Studio's MSBuild is missing the JoinItems task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment