Code Monkey home page Code Monkey logo

msbuildgithash's People

Contributors

brent-zeiss avatar drdamour avatar jasontaylor137 avatar koalabear84 avatar lordmike avatar markpflug avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msbuildgithash's Issues

The MSBuildGitHash did not work

Hi,

  • I have install the nuget package of this project on https://github.com/chucklu/Utility.
    After I build the project, the git hash is not embedded in version of *.dll.

  • I also tried to run the unit test demo, only the demo for LegacyProjectTest works, SdkProjectTest demo failed with restore error. And the demo project is not a normal one, such as a project have AssemblyInfo.cs .

  • I also found you have used git bash in https://github.com/MarkPflug/Elemental.SysInfoTool, I clone this project and build it. When I verify the version, nothing related to git hash.

Adding an annotated tag causes build error

I managed to reproduce the problem in a new project by adding a one-letter annotated tag:
git tag -a B

I got the error:
MSBuildGitHash hash value starting with 'B-0-g91456ff' was invalid.

Multiple commands / outputs

I would like to know if it's possible to combine the output of multiple commands.

git branch --show-current
git rev-list --all --count
git describe --long --always --dirty

Which will create something like:
develop-9657-8f52fbc74-dirty

No informational version with latest .net core version

MSBuildGitHash 2.0.1 doesn't seem to generate an informational version with .netcore3.1

Steps to reproduce:

  • Create a new .netcoreapp3.1 project in VS2019
  • Add MSBuildGitHash-2.0.1 nuget
  • Build

(Used .net core 3.1.6)

=> The informational version is still 1.0.0. (the default) but the AssemblyMetadata GitHash is included correctly.

[Minor] Readme

Under: Git hash format

(first 8 hex characters)

should be

(first 7 hex characters)

Thoughts on Adding Commit Hash Always and a Data Class

hi, we're currently using this, but a couple of use cases came up and wanted to see if you think these would fit in your vision or if it's better for us to fork.

  1. We have a need to ALWAYS have BOTH the commit hash & the output of git describe --tag (which generally is a tag). Are you open to adding a 2nd overridable command that ends up with metadata name GitDescribe ?
  2. We need to read this data across all .net apps, so want to include a simple util class that does the reflection code in it's constructor (or some factory like pattern) to expose the meta values created by this build process (namely GitHash and GitDescribe). I know this package has no classes today, so this would be a change.

if these do align, we can get a PR going. let me know your thoughts.

Change request: A way to conditionally disable MSBuildGitHash

I want to disable MSBuildGitHash in Debug config because it increases compilation time, but useless in debug for me.

Also it seems that project may rebuild because of MSBuildGitHash even if nothing changed in the project.
For example when I edit tests main project also recompiled even if it wasn't changed.

MSBuildGitHashCommand causes build to fail if there is no .git folder

Is it possible to ignore a missing .git folder and include a dummy value?

Sometimes we download old commits of our software to quickly test items out and the build will obviously fail due to there being no git repo. This is not immediately obvious to some of our team members.

Or alternatively just make it a warning?

Thanks

AssemblyMetadataAttribute GitHash not in file properties

Hi there,

When looking at the File properties I see that the GitHash property is missing. Only product version contains the hash
image

Using v2.0.1, I was able to access this through "AssemblyMetadataAttribute" with name GitHash
Not sure if something has changed since?

MSBuildGitHashSuppressDirtyWarning not working in 2.0.0

Hi there,

A great library, I noticed in v2.0.0 that <MSBuildGitHashSuppressDirtyWarning>true</MSBuildGitHashSuppressDirtyWarning> no longer works and the message gets emitted

As a sidenote I noticed when using Resharper I tend to get messages on the bottom stating sync solution I think it's every time a file might be getting changed while developing. Not sure if it's related, but if it is, is there is a way to prevent MSBuildGitHash from running locally?

Commit not updated if you build from dirty, then commit, then build again

If I make some changes, then build, then commit and then build again without making additional changes, the Git hash will not be updated.

This is because without source files being touched the MSBuild Targets will not be executed at all and the project will show "Everything up-to-date".

The best solution would be to check if the HEAD has changed and regenerate the AssemblyInfo.cs only if the commit has changed, but do nothing if the commit wasn't changed.

A slightly worse solution would be to always regenerate but this would break the "Everything up-to-date" - the project will always be built even if nothing was changed including the commit.

Default hash fails with tags

by default

git describe --long --always --dirty

Can use the tags leading to errors
Example:
MSBuildGitHash hash value starting with 'docker-version-dirty' was invalid.
that is the shortend value of
docker-version-0-g662b733-dirty

this fixs that issue

git describe --match=NeVeRmAtCh --always --abbrev=7 --dirty

<PropertyGroup>
  <MSBuildGitHashCommand>git describe --match=NeVeRmAtCh --always --abbrev=7 --dirty</MSBuildGitHashCommand>
</PropertyGroup>

Update issue 1.0.2 -> 2.0.1

The following message
fatal: No names found, cannot describe anything.
is added to the output when you build, it does not stop the build itself and the version number seems correct, I think this might be looking for a tag and failing if there are none.

the issue goes away if you restore the old version.

Is MSBuildGitHash not working without network connection?

On 2 of my machines MSBuildGitHash is working like a charm. However, I do have one machine which is not connected to the internet (and will not be connected). On this machine my project starts throwing many compilation errors (e.g. Type Exception not known, ...). Once I uninstall MSBuildGitHash everything is working like normal.

I copied my whole project including packages folder which contains MSBuildGitHash from a machine (with network connection) where everything works smoothly onto the machine which shows these wired errors.

Any ideas or do you need additional information?

Special character sequences in git commands

This is for other people's future reference. I was using the MSBuildGitHash Nuget package v2.0.2.

While trying to run some custom git commands to capture additional information, I ran into problems with character sequences that needed to be escaped.

  • % needs to be escaped as %%
  • ae needs to be escaped as a%e
  • cd needs to be escaped as c%d

These are the git commands I was trying to run:

  • git show --quiet --format=%ae
  • git show --quiet --format=%an
  • git show --quiet --format=%cd --date=iso-strict
  • git show --quiet --format=%B
  • git show --quiet --format=%H

This is the corresponding ItemGroup with correctly escaped character sequences:

  <ItemGroup>
    <AssemblyMetadataCommand Include="GitAuthorEmail">
      <Command>git show --quiet --format=%%a%e</Command>
    </AssemblyMetadataCommand>
    <AssemblyMetadataCommand Include="GitAuthorName">
      <Command>git show --quiet --format=%%an</Command>
    </AssemblyMetadataCommand>
    <AssemblyMetadataCommand Include="GitCommitDate">
      <Command>git show --quiet --format=%%c%d --date=iso-strict</Command>
    </AssemblyMetadataCommand>
    <AssemblyMetadataCommand Include="GitCommitMessage">
      <Command>git show --quiet --format=%%B</Command>
    </AssemblyMetadataCommand>
    <AssemblyMetadataCommand Include="GitFullHash">
      <Command>git show --quiet --format=%%H</Command>
    </AssemblyMetadataCommand>
  </ItemGroup>

There may be other character sequences that require escaping which I am not yet aware of.

Deativate Output / Redirect stdout

Is there a way to deativate the standard output from git describe?

I tried to pipe the git describe output to /dev/null but it doesn't seem to work.

Invalid validation for the git version

I failed to build my solution with error:

C:\repo\packages\MSBuildGitHash.0.2.0\build\MSBuildGitHash.targets(29,5): error : MSBuildGitHash hash value starting with 'Roll_1.0-232-g474e3a4-dirty' was invalid.

Where "Roll_1.0" is a label used some time ago in history.
It seems that MSBuildGitHash doesn't work with labels.

It is said that I can somehow customize the validation but there is no any wiki how to do it,

Commit not updated on unrelated changes

This is a rehash (he!) of #5 When building again after moving to a revision with changes only on files outside the project, msbuild thinks the project is up-to-date and fails to rebuild it.

Doesn't provide git hash :)

Thanks for making this cool package. For those of us that aren't intimate with MSBuild, this is a real time saver.

Given the name of this package, I was somewhat surprised to find that the git hash isn't what is provided. For that you would want to do something like git rev-parse HEAD in stead of git describe.

It would probably improve the utility of this package if it were possible to override the specific git command used to extract version information. As it stands, I had to include your targets directly in my .csproj and modify the git command there in order to actually get the git hash.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.