Bodrick
Bodrick

Reputation: 342

Obtaining a list of resolved reference paths in msbuild

I'm trying to use ILMerge to merge multiple assemblies into one plugin assembly, which will be dynamically loaded by another application.

Using the community tasks, I've so far got:

<Target Name="CombineAssemblies" AfterTargets="MvcBuildViews">
    <ItemGroup>
        <MergePaths Include="@(_ResolvedProjectReferencePaths)" />
        <!--<MergePaths Include="%(Reference.ResolvedPath)" /> This doesn't work! -->
    </ItemGroup>

    <ILMerge
        DebugInfo="true"
        LogFile="log.txt"
        InputAssemblies="@(MergePaths)"
        OutputFile="&quot;$(TargetPath)&quot;"
        CopyAttributes="true"
        TargetPlatformVersion="v4"/>
</Target>

Using @(_ResolvedProjectReferencePaths) works fine for the project references, and their paths are passesd correctly through to the ILMerge task.

When running this through MSBuild, ILMerge.exe errors out. Looking at the log file, I get:

Unresolved assembly reference not allowed: System.Web.Mvc.
   at System.Compiler.Ir2md.GetAssemblyRefIndex(AssemblyNode assembly)
   at System.Compiler.Ir2md.GetTypeRefIndex(TypeNode type)
   at System.Compiler.Ir2md.VisitReferencedType(TypeNode type)
   at System.Compiler.Ir2md.VisitMethod(Method method)
   at System.Compiler.Ir2md.VisitClass(Class Class)
   at System.Compiler.Ir2md.VisitModule(Module module)
   at System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation)
   at System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation, BinaryWriter writer)
   at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName)
   at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module)
   at ILMerging.ILMerge.Merge()
   at ILMerging.ILMerge.Main(String[] args)

I'm referencing the MVC libraries, which from the log file I assume could not be resolved by ILMerge, even though they are resolved correctly in the actual compilation process.

I therefore want to pass the location of these libraries through to ILMerge, ideally using the References item so I don't have to manually add a bunch of reference paths which would have to change if I added or removed references. Is there some equivalent to @(_ResolvedProjectReferencePaths) for normal references?

Thanks!

Upvotes: 1

Views: 846

Answers (1)

radical
radical

Reputation: 4424

Try @(ReferencePath), which should be used after target ResolveAssemblyReferences.

Upvotes: 3

Related Questions