1

I have found many many answers in stack overflow and tips around the web recommending to use that, and i realize that it suppose to copy referenced dll's to the output folder. I want to understand that target's logic and how to use it properly, and so far I couldn't find anything around the web explaining it. There was one line on it in MSDN

In my project I get the dll's in the root output folder, not in the "Bin" folder, which is three levels down so I don't really see the point of it. I'd rather get a full explenation than a solution to my one time problem. Thanks in advance

<Target Name="BuildSolutionWithConfig">
    <Message Text="Build: $(BuildType) $(SolutionFileName)"></Message>
    <MSBuild Projects="$(SolutionFileName)" Targets="_CopyWebApplication; ResolveReferences" Properties="Configuration=$(BuildType);OutputPath=$(BuildOutputPath);"></MSBuild>
    <JsAndCssUpdater Path="$(FullPath)" Version="$(JsVersion)" PathToSaveLogAndBackup="$(PathToSaveLogAndBackup)"/>
    <MSBuild.ExtensionPack.Compression.Zip ZipFileName="$(BuildOutputPath)\..\$(BuildType).zip" CompressPath="$(BuildOutputPath)" TaskAction="Create"/>
</Target>
Yuval Perelman
  • 4,499
  • 1
  • 22
  • 32

1 Answers1

2

By default, at least in MSBuild 12.0, the ResolveReferences target literally does nothing itself. It just depends on a number of other targets. From %PROGRAMFILES%\MSBuild\12.0\Bin\Microsoft.Common.CurrentVersion.targets:

  <!--
    ============================================================
                                        ResolveReferences
    ============================================================
    -->
  <PropertyGroup>
    <ResolveReferencesDependsOn>
      BeforeResolveReferences;
      AssignProjectConfiguration;
      ResolveProjectReferences;
      FindInvalidProjectReferences;
      ResolveNativeReferences;
      ResolveAssemblyReferences;
      GenerateBindingRedirects;
      ResolveComReferences;
      AfterResolveReferences
    </ResolveReferencesDependsOn>
  </PropertyGroup>
  <Target
      Name="ResolveReferences"
      DependsOnTargets="$(ResolveReferencesDependsOn)"/>

To my knowledge, none of the default targets in $(ResolveReferencesDependsOn) actually copy the files to your output directory either. Rather, these targets identify where the files are and, in some cases, cause other projects to be built so that the files are available. Because <MSBuild> tasks can specify the locations of their outputs, it should not matter where the target actually puts the files as long as the (for example) ResolveProjectReferences target can access them from the paths that <MSBuild> returns.

Andrew
  • 14,325
  • 4
  • 43
  • 64
  • Thanks, but that doesn't really help. I get the needed dlls in the bin folder, but when i add that target i ALSO get a bunch of dlls in the root folder. I don't really need these dlls, but I do want the dll files used in the bin folder to be rebuilt. I really want to understand what's going on, why these files are copied and why to the root folder. The other option is to hope all goes well during deployment, and we're trying to avoid that. In general, I don't like using technologies I dont understand, and unfortunately I didnt find anything about the tagets it depends on either. – Yuval Perelman Mar 29 '15 at 11:11
  • @user2033402 Could you edit your question to include the relevant parts of your .csproj (or other project) file? It would be somewhat unusual to call `ResolveReferences` explicitly because the default build process already calls it, so it would help if I could see what you are trying to do. – Andrew Mar 29 '15 at 11:40
  • Updated. Maybe that behaviour is caused by combination of ResolveReferences and _CopyWebApplication but I want to know why – Yuval Perelman Mar 29 '15 at 11:57