Skip to content

Build task dependencies vs target framework #24

Open
@dazinator

Description

@dazinator

So I have noticed the following issue!

I have a very simple repro project, that consumes GitVersionTask
I have created multiple branches, in each branch I have amended the project to target a particular target framework/s. The name of the branch is named after the target frameworks that the project is targeting.
These branches all build on appveyor.

I have found that in some scenarios, the task does not run.

Target Framework Runs ?
netstandard1.1 No
netstandard1.3 No
netstandard1.5 Yes
netcoreapp20;netstandard1.1 Yes

You can see all the relevant builds here: https://ci.appveyor.com/project/dazinator/gitversion-pr1269/history

So what is interesting is that the task doesn't seem to run until the consumer project is targeting atleast netstandard1.5 or a platform that is compatible with netstandard1.5 (i.e netcoreapp20).

I think this is down to the fact that the GitVersionTask nuget package has the following in its nuspec:

<dependencies>
      <group targetFramework=".NETStandard1.5">
         <dependency id="UtilPack.NuGet.MSBuild" version="$utilpackversion$" exclude="Build,Analyzers" />
         <dependency id="GitTools.Core" version="$gittoolscoreversion$" exclude="Build,Analyzers" />
         <dependency id="YamlDotNet" version="$yamldotnetversion$" exclude="Build,Analyzers" />        
      </group>
      <group targetFramework=".NETFramework4.6.1">
         <dependency id="UtilPack.NuGet.MSBuild" version="$utilpackversion$" exclude="Build,Analyzers" />      
      </group>
    </dependencies>

The sole reason this is there is because we rely on UtilPack to use this information to know how to restore / and resolve dependencies for us prior to executing the task.
However this is a problem. By listing dependencies in the nuspec we are effectively telling MsBuild to ingore the package if te consumer is targeting an incompatible framework. This is not what we want as the tool is a build tool, it's dependency chain is fixed based on the build environment, and not the target framework that a consumer is targeting.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions