ygoe / netrevisiontool Goto Github PK
View Code? Open in Web Editor NEWInjects the current VCS revision into a .NET assembly build.
Home Page: https://unclassified.software/apps/netrevisiontool
License: GNU General Public License v3.0
Injects the current VCS revision into a .NET assembly build.
Home Page: https://unclassified.software/apps/netrevisiontool
License: GNU General Public License v3.0
Hello,
it would be a great addition to be able to get an auto-increased serial number. A possible format for this is:
[assembly: AssemblyInformationalVersion("1.5.{sernum:1250}-{chash:6}")]
On execution of NetRevisionTool ...
1.5.1251-abcdef
is used for compilation1.5.{sernum:1251}-{chash:6}
is written to the original file.When the increased number is greater than 65535, it is automatically reset to 1 (or 0?).
We are just rolling out updates to our projects to include use of your tool. This all went fine when I initially tested it out on a sample project.
But on a coworker's machine we added the same changes to a different project but get odd results after the build.
Here is the assembly info string we're using:
[assembly: AssemblyInformationalVersion("{b:uymd-} {b:uhms:} -> {cname} -> {branch} -> {CHASH:8} {!:(Warning - There were uncommited changes present)}")]
But here's the output we see for the generated assembly:
2016-10-24 18:39:33 -> -> -> 00000000
His project sits within a local Git repo just as mine does, but I see all of the expected values in my generated DLL but his are missing and has commit ID all zeros, no branch name or committer name.
It's as if the tool is unaware of his repo or has no access to its metadata, but I don't know how this could happen.
The build output window reports no errors or warnings and we use Visual Studio 2015 and 2013.
Hi,
Do you think its possible to also get the name of the repo? we have multiple repos and sometimes branch/commit ID is not always obvious to some staff who want to get to our code.
Being able to include repo name would be HUGE for us!
Thx
Hi,
I looked a coworkers machine (on which NetRevisionTool was not finding Git) and here is where SmartGit had installed Git:
C:\Program Files (x86)\SmartGit\git\bin\git.exe
For some reason, SmartGit installs that surreptitiously in its own folder.
Thanks
Hi,
I'm thinking about adding a new capability here, one that lets us specify (in the command args) the URL of our organization. Then because I already added support for getting repo name {repodir} it's possible to construct the URL to a commit and embed this in the ProductVersion attribute.
Do you have any concerns or reservations about this in general?
Consider support for including the computer name where a build ran. This is helpful if code is built and deployed by a developer from their own machine and for some reason we need to build from that same machine (for whatever reason).
Idea is, that the template is in the AssemblyInfo.cs
commented out by //
, e.g.
/// template: [assembly: AssemblyInformationalVersion("1.0.{revnum} {c:ymd-}")]
The NetRevisionTool.exe
will create a new file AssemblyInfoGenerated.cs
:
[assembly: AssemblyInformationalVersion("1.39.50_a34fd2")]
The user has to include the AssemblyInfoGenerated.cs
into the build process, but exclude it from VCS control (.gitignore
).
The main advantage is, that it does not need /restore.
.NET Core projects (.csproj) in Visual Studio 2017 (15.3) define the assembly and NuGet package version inside the .csproj file instead of a separate .cs file with assembly attributes. NetRevisionTool should detect these situations and patch the project file instead (hopefully that works because the tool will be called from build events defined in the same file). This includes the NuGet package version.
Example project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.0-rc</Version>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.2.0.0</FileVersion>
<InformationalVersion>1.3-rc</InformationalVersion>
</PropertyGroup>
</Project>
The version properties can be added at the end of the .csproj file in a separate unconditional <PropertyGroup>
and override whatever was defined in the project before (if anything).
The version format string can be defined in a custom XML element like <VersionFormat>
. So the format is no longer defined and resolved in place but rather read from a separate location and added as new the version elements.
Ocassionally when I do a build, I see the version message in the final DLL indicating there were uncommitted changes, but no changes were pending.
It seems that sometime NetRevisionTool/Git see the modified AssemblyInfo.cs file and backup and for a brief interval detect uncommitted changes, once the build is done these revert by themselves and there are no changes.
Here's another project that installs and uninstalls a tool program in MSBuild through a NuGet package.
http://einaregilsson.com/module-initializers-in-csharp/
We should be able to do the same with NetRevisionTool. This should also avoid putting the call in the Pre/PostBuildEvent and setting it to "Always" which may interfer with other PostBuildEvent commands.
Customising the NetRevisionTool command-line arguments would however require editing the .*proj file then.
Error MSB3073: The command ""E:\C#\VS2012<project name>_scripts\bin\NetRevisionTool.exe" /patch "E:\C#\VS2012<project name><project name>"" exited with code 100. (1, 1)
Recently at my work machine i get this error, and looks like i can't even fix it anymore. Previously, and occasionally this error popped up, but all i had to do is to reset 'AssemblyInfo.cs' in git, and everything built after that.
But right now, this don't seems to help. Even more interesting is that the same solution at home (everything is the same) builds just fine. Also this is not limited to this solution, everything else that uses NRT fails now.
I'm using NRT as pre/post build, Run the post-build event is on Always.
Hi,
Thanks for making those recent changes by the way.
We want to include a time-zone for the time setting strings, here's why - we have developers onshore (AZ Usa) and offshore (India). If we use local time in our projects then stuff we build locally will have a meaningful time but stuff built offshore will have a time pertaining to the local time in India which will eventually confuse us all.
Therefore we've been using UTC but of course that time (although consistent whether built onshore/offshore) is also a bit confusing for support staff here in AZ.
So we'd therefore like to have the times be local AZ time no matter who builds the code.
I could do this and create a pull request or if you feel you'd like to do it, then that's fine - please let me know.
Thx
Just a note, I blogged about this tool here: https://korporalkernel.com/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.