msbuildmsbuild-task.net-standard-2.0msbuild-target

MsBuild SDK project style: project dependencies sometimes fails


In the solution I have some dependent project configured as SDK style projects:

Based on that Proj A should be fully compiled before running task on Proj B compilation. Both projects has different compilation target (NetStandard20 and Net462). Therefore I couldn't make a direct reference but do solution-wide project dependency with setting property AddSyntheticProjectReferencesForSolutionDependencies as false (otherwise msbuild tries to make project dependency forcible).

In that setup, MsBuild sometimes fails on compilation: Proj A started to compile but haven't finished in time when Proj B run the task. MSBuild is started on CI machine with key /m.

Any ideas are welcomed.


Solution

  • In this case you actually do want a synthetic project reference but there is a subtle issue in MSBuild at the moment that creates some issues across project references if the project having the dependency is multi-targeting. This is fixed in 15.9.

    Please try it out in the visual studio preview version of 15.9 (at the time of writing: 15.9 Preview 2).

    If you don't want to wait, you can add a similar project reference in the csproj file yourself:

    <ItemGroup>
      <ProjectReference Include="..\other\project.csproj"
        ReferenceOutputAssembly="false"
        LinkLibraryDependencies="false"
        CopyLocal="false"
        SkipGetTargetFrameworkProperties="true"
        GlobalPropertiesToRemove="TargetFramework"
        />
    </ItemGroup>