none
How to force MsBuild to use existed dll? RRS feed

  • Question

  • How to force MsBuild to use existed dll?

    I have folloving (simplified) definition in csproj file:

      <Choose>
        <When Condition=" '$(CCNetBuildId)' == '' AND '$(BatchBuild)' == '' ">
          <ItemGroup>
            <ProjectReference Include="..\GPS.Order.Factory\GPS.Order.Factory.csproj">
              <Project>{f3cd6b63-0312-4708-9c99-18232a20d21e}</Project>
              <Name>GPS.Order.Factory</Name>
            </ProjectReference>
          </ItemGroup>
        </When>
    	<When Condition=" '$(BatchBuild)' == 'true' ">
    		<ItemGroup>
    			<Reference Include="GPS.Order.Factory">
    				<SpecificVersion>False</SpecificVersion>
    				<HintPath>GPS.Order.Factory.dll</HintPath>
    				<Private>False</Private>
    			</Reference>			
    		</ItemGroup>
        </When>
    
        <Otherwise>
          <ItemGroup>
            <Reference Include="GPS.Order.Factory" />
          </ItemGroup>
        </Otherwise>
      </Choose>

    Idea was - when I use a standard Studio build (not CruiseControl or my own batch file) will be compiled 

    GPS.Order.Factory.csproj

    if I use batch build - will be used dll in working folder.

    In any other case (CruiseControl build) will be used any suitable (most likely - from working folder) instance of dll.

    If something goes wrong - an error report expected.

    But behavioure of MsBuild are different from expected.

    On batch and CC builds MsBuild picked up DLL from OBJ folder of Gps.Order.Factory.csproj. Usually there are wrong DLL.

    How do I suppress picking up wrong DLL?

    I rememeber that I already do ask something similar when Studio 2015 was released and problem was confirmed.

    But looks like the problem remain on place.


    Sincerely, Highly skilled coding monkey.

    Tuesday, November 26, 2019 12:15 PM

All replies

  • Hi Andrey,

    Welcome to MSDN forum.

    Thanks for these detials. I try to reproduce this issue on my side. When I set <HintPath>xxx.dll</HintPath>, the dll could not be found. We recommend you could try to set the directory to 

    <HintPath>..\GPS.Order.Factory\bin\Debug\GPS.Order.Factory.dll</HintPath>

    Any feedback will be expected.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, November 27, 2019 7:44 AM
  • Hello Dylan,

    I new that I can specify DLL in OBJ or BIN\Release[DEBUG] folder. It's not what required. Required to prevent using of this DLL.

    Problem I have - I suppouse to use different, build previously, DLL from specific folder, but MsDuild still picking up the DLL from BIN\* when this specified(hinted) DLL are missing.

    DLL in BIN\* is not a one which need to be used, but it picked up if requested(hinted) DLL are missing. It's picked up even when ProjectReference are unavailable regards to the Condition's.

    For better understanding:

    <When Condition=" '$(UseClientSpecific)' == 'Margo LLC' ">
    	<ItemGroup>
    		<Reference Include="GPS.Order.Factory">
    				<SpecificVersion>False</SpecificVersion>
    				<HintPath>..\Clients\$(UseClientSpecific)\GPS.Order.Factory.dll</HintPath>
    				<Private>False</Private>
    			</Reference>			
    		</ItemGroup>
        </When>
    Build failure in case that DLL missing are expected, but build secceed using incorrect version of DLL.


    Sincerely, Highly skilled coding monkey.

    Wednesday, November 27, 2019 9:26 AM
  • Hi Andrey Belyakov,

    Thank you for mention.

    It looks like the Hint Path doesn't work, you could have a try this method:

        <Reference Include="$(SolutionDir)\Clients\$(UseClientSpecific)\GPS.Order.Factory.dll">
          <Private>False</Private>
          <Name>GPS.Order.Factory</Name>
        </Reference>

    In addition, you could also try "$(SolutionDir)" with HintPath tag

        <Reference Include="GPS.Order.Factory">
          <HintPath>$(SolutionDir)\Clients\$(UseClientSpecific)\GPS.Order.Factory.dll</HintPath>
          <Private>False</Private>
        </Reference>

    Any feedback will be expected.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, November 28, 2019 8:56 AM
  • I can put reference t DLL in different format - this is not a problem.

    Problem is:
    when I have in the project BOTH:
    - false condition for the ProjectReference for a project
    and
    - true condtion for the Reference to the DLL and DLL are missing
    MsBuild still assemble the project using ProjectReference and ignoring false condition.

    Yes, it's assembled witout errors, but didn't work properly regards to the wrong version of DLL.


    Sincerely, Highly skilled coding monkey.

    Thursday, November 28, 2019 10:33 AM
  • Hi Andrey Belyakov,

    From your latest post, you could install the latest msbuild tool to build this csproj file, then check if it could work.

    If the issue persists, we recommend you could go to Msbuild Github to report this issue. 

    Hope it could help you.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Tuesday, December 3, 2019 9:22 AM