Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong version constraint when building dependant libraries using ProjectReference and GitVersion #5003

Closed
thoemmi opened this issue Apr 10, 2017 · 5 comments

Comments

@thoemmi
Copy link

thoemmi commented Apr 10, 2017

I have a solution with two library projects, using VS2017. Project B has a ProjectReference to A. The version are determined at compile time by GitVersion (4.0.0-beta0011). The current version of my libraries is 0.1.0.

I create the NuGet packages using msbuild:

msbuild /t:restore;build;pack

While both packages have the version 0.1.0, the nuspec of B says it depends on A, version 1.0! However, v1.0 doesn't exist, so you cannot add package B to any project.

You can reproduce the issue with my repository StickyWindows: StickyWindows.WPF depends on StickyWindows, version >= 1.0 (see NuGet gallery), though both packages are 0.1.0, created with the same build.

@thoemmi
Copy link
Author

thoemmi commented Apr 10, 2017

I also tried msbuild /t:restore;build /p:GeneratePackageOnBuild=true, but the result is the same.

@rohit21agrawal
Copy link
Contributor

@thoemmi restore and build should not be done in one msbuild session. Could you try executing them separately to see if the problem still persists?

@emgarten will be better able to explain why restore and build should not be run in one msbuild session.

@thoemmi
Copy link
Author

thoemmi commented Apr 10, 2017

The result is the same if I call MSBuild for each target separately.

@rohit21agrawal
Copy link
Contributor

@thoemmi i think this is a dupe of : #4790 . There is a workaround listed there too . If you think that's the issue, can you please close this out and subscribe to that issue for updates?

thoemmi added a commit to thoemmi/StickyWindows that referenced this issue Apr 11, 2017
@thoemmi
Copy link
Author

thoemmi commented Apr 11, 2017

@rohit21agrawal I can confirm that the referenced workaround does work. I've created following file and imported it in my .csproj's:

<Project>
  <!-- GitVersion version -->
  <PropertyGroup>
    <GitVersionTaskVersion>4.0.0-beta0011</GitVersionTaskVersion>
  </PropertyGroup>

  <ItemGroup>
    <!-- reference GitVersionTask package -->
    <PackageReference Include="GitVersionTask" Version="$(GitVersionTaskVersion)" PrivateAssets="All" />
  </ItemGroup>

  <!--
    Import GitVersionTask target
    This ugly workaround is necessary because of this NuGet issue: https://github.com/NuGet/Home/issues/4790
  -->
  <ImportGroup Condition="'$(ExcludeRestorePackageImports)' == 'true'">
    <Import
      Project="$(UserProfile)\.nuget\packages\gitversiontask\$(GitVersionTaskVersion)\buildMultiTargeting\GitVersionTask.targets"
      Condition="Exists('$(UserProfile)\.nuget\packages\gitversiontask\$(GitVersionTaskVersion)\buildMultiTargeting\GitVersionTask.targets')" />
  </ImportGroup>
  <Target
    Name="FixUpVersion"
    BeforeTargets="_GenerateRestoreProjectSpec"
    DependsOnTargets="GetVersion"
    Condition="'$(GitVersion_Task_targets_Imported)' == 'True'" />
</Project>

I'll close this issue and subscribe to #4790 as requested.

@thoemmi thoemmi closed this as completed Apr 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants