Targetting different Frameworks using MSBuild gives problems with dependencies

前端 未结 1 1953
谎友^
谎友^ 2021-02-11 06:30

I have a little project, and I want to have 2 compiled versions of that project:

  • one that is targetting the .NET 2.0 framework
  • one that is targetting the
相关标签:
1条回答
  • 2021-02-11 07:17

    I've been revisiting this problem again, since I do not like to have to manually change the csproj file. (When I change my reference, I must not forget to adapt the csproj file again, to set the Private node to true again).

    So, I've been digging into MSDN, and I stumbled upon this:

    ResolveAssemblyReference.TargetFrameworkDirectories Property

    Remarks This property is required to determine the CopyLocal status for resulting items.

    If this property is not specified, no resulting items will be have a CopyLocal value of true unless they explicitly have a Private metadata value of true on their source item.

    So, this means that there is yet another possibility, and that is to set the TargetFrameworkDirectories of the ResolveAssemblyReference task. However, is there anybody out there who knows how to do this ?
    I've been trying different things, but nothing seems to be working ...

    I've tried this:

    <ItemGroup>
        <TargetFrameworkDir Include="$(SystemRoot)\Microsoft.NET\Framework\v2.0.50727" />
    </ItemGroup>
    
    <PropertyGroup>
       <TargetDirsToUse>@(TargetFrameworkDir)</TargetDirsToUse>
    </PropertyGroup>
    
    <ResolveAssemblyReference TargetFrameworkDirectories="$(TargetDirsToUse)" />
    

    But to no avail ... Maybe someone else knows how to do this, or has a golden tip. (I've been spending way to much time on this f*cking issue).

    0 讨论(0)
提交回复
热议问题