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

csproj example #62

Closed
piccaso opened this issue Feb 19, 2018 · 3 comments
Closed

csproj example #62

piccaso opened this issue Feb 19, 2018 · 3 comments

Comments

@piccaso
Copy link

piccaso commented Feb 19, 2018

Can someone please share a working .csproj example?
Or tell me wrong what is wrong with mine:

<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="GitVersion">
  <PropertyGroup>
    <TargetFrameworks>netstandard1.0;net40</TargetFrameworks>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    <version>$(GitTag)</version>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="GitInfo" Version="2.0.8" PrivateAssets="all" />
  </ItemGroup>
</Project>

Thanks!

@bvli
Copy link
Contributor

bvli commented Feb 21, 2018

I have this in my ./src/Directory.Build.props:

  <ItemGroup>
    <PackageReference Include="gitinfo" Version="2.0.8" />
  </ItemGroup>

  <PropertyGroup>
    <GitInfoReportImportance Condition="$(Configuration) == 'Release'">high</GitInfoReportImportance>
  </PropertyGroup>

  <Target Name="Configure" AfterTargets="GitInfoReport">
    <PropertyGroup>
      <Version>$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)$(GitSemVerDashLabel)</Version>
    </PropertyGroup>
  </Target>

It works quite well.

/B :)

@kzu
Copy link
Member

kzu commented Feb 22, 2018

The Git* properties are populated when the GitInfo target runs (and the version ones when GitVersion runs).

You can't reference those properties before those targets have run. The updated docs on MSBuild go into quite a bit more details on how properties/items/targets are evaluated and run and when. It might be worth checking those out, they are quite well written, I'd say: https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-properties

@kzu kzu closed this as completed Feb 22, 2018
@devlooped devlooped locked and limited conversation to collaborators Sep 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants