Visual studio file version auto increment


















However the landscape has changed and VS supports doing some build-time stuff even in VS using a custom directory. You can also do versioning there. We do that for our stuff now and it versions whenever anyone builds although we turn it off for local builds.

More importantly you can put your version information into a directory. To auto-increment the you'll need to decide the rules to use. You cannot simply look at the last version because it is probably already gone. Most people tend to use a time of day or something in build systems they tend to provide a revision number. If you want something more advanced than what the wildcard support in AssemblyVersion handles then you'll need to go this route. But honestly I'd just stick with AssemblyVersion wildcards unless you really, really need customized versioning.

I actually am in the process of coming up with another way to do this in a custom build. I added this console app to global. What I want to do is invoke the console app in a post build event and the console app writes the file to the application root.

This is where I need assistance because I'm not sure what to specifically put in the build event. I did some research and do I put in like an xcopy type of thing for this? If someone can assist me with this I would greatly appreciate it. I really don't recommend you go that route. The app version is determined by the binary file, not some config file at runtime. There are many, many tools available to auto-increment your versioning at build time.

This is when it needs to happen. You haven't specified how you build your "official" version so it is hard to say. I would personally say use a directory. At build time increment the patch by 1. This is easily done using Powershell which can be triggered by a directory. Then your assembly ies have the correct version. It then becomes a simple matter in your app to get the version from the assembly. This is how our apps get their version info for our users and it works very well. I thought that I had specifically stated how i wanted to build the official version.

Maybe not. Anyway the version number should auto increment the build number portion of the assembly everytime me or someone else does a build on the project. It should start with version number 1. I want to display that version number as a counter of sorts on the login page of the website.

I reviewed the directory. I haven't done something like that. Does that align with what I described in the paragraph above of what I'm trying to accomplish?

Are you sure that is the way you want to go? Are you using version control? If so then every time somebody does a build, irrelevant if they change anything then your assemblyinfo. Given that you'll likely be making changes and rebuilding your code over and over again as you fix compiler errors and logic errors then the version will increment.

Given that you are using a 3 digit value then you only get builds which doesn't sound like much until you consider how often you do builds throughout the day. Normally you would only want to do that for a "potentially releasable" build. Hence normally this is done via your build system. Although you could also configure it to only happen for Release builds in VS as well and that would alleviate the continual changes.

I'm afraid you cannot do that. As I already mentioned, Windows requires version s to be 4 parts and it'll ignore any zero prefixes.

Just to change or add the below two lines in the file. The solution is to empty all 4 boxes in the File Version row.

That way the File Version will be generated same as the Assembly version. If you edit the AssemblyInfo. Revision number will change every build, but randomly, rather than in an incrementing fashion. This is probably enough for most use cases. If that's not what you're looking for, you're stuck with having to write a script which will autoincrement version on pre-build step.

DrewChapin's script works, but I can't set different modes for Debug pre-build event and Release pre-build event in my studio. You could try using UpdateVersion by Matt Griffith. It's quite old now, but works well. To use it, you simply need to setup a pre-build event which points at your AssemblyInfo. As the application is open-source, I've also created a version to increment the version number using the format Major version.

Minor version. You can do more advanced versioning using build scripts such as Build Versioning. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to have an auto incrementing version number Visual Studio?

Asked 12 years, 8 months ago. Active 5 months ago. Viewed k times. Add a comment. Active Oldest Votes. If you add an AssemblyInfo class to your project and amend the AssemblyVersion attribute to end with an asterisk, for example: [assembly: AssemblyVersion "2.

AddDays version. AddSeconds version. Newer versions of Visual Studio give this error: this thread begun in The specified version string contains wildcards, which are not compatible with determinism. Venkat 2, 2 2 gold badges 22 22 silver badges 54 54 bronze badges. Noel Kennedy Noel Kennedy I recommend always using " X.

Instead of using the number of days since year ? How should you get this change back into source control? BTW, you don't really have to edit and add in the assembly info file. Visual studio will take care of update the. Show 21 more comments. You could use the T4 templating mechanism in Visual Studio to generate the required source code from a simple text file : I wanted to configure version information generation for some.

Here what should be done: Create a file with extension ". Reflection; [assembly: AssemblyVersion "1. Remember to set the path. The console app will run each time there is a build which will update the Version. Got a question about the Global.

I get 'The name 'RouteTable' does not exist in the current context when I add that code to the file. What do I need to do to fix those errors? I'm not sure what you are doing Post your original Global. This was the code in the handler before I pasted. I tried my previous suggestion which seems to work out of the box ie using [ assembly : AssemblyVersion "1. All the same error 'The name 'RouteConfig' does not exist in current context.

And yes I agree that using [ assembly : AssemblyVersion "1. Yeah, you posted the non-highlighted code. Only post the highlighted code. That's why I highlighted it More generally you should have a "light bulb" on this kind of errors and you should then see suggestions such as using the full name ie someNameSpace.

RouteConfig or to add a using NameSpace; directive at the top of your file. It could be also that a namespace declaration is missing AFAIK it is common to declare MvcApplication and RouteConfig in the same namespace in which case you won't have this issue. For the JsonSerializer error I get 'the type or namespace 'JsonSerializer' could not be found' and the light bulb suggestion is to generate a class for that in a new file. That doesn't sound right. OK now I need to get the label or whatever on the master page to show the version number on the login page.

Here is the code I have but it doesn't seem to work. OK now I need to get the label or whatever on the master page to show the version number. Using that span I don't get anything to show. I'm not using it in the footer. This is what I have the label for the word 'Build' and then the span tag:. You'll need to set a breakpoint and step through the code to make sure the application variable is set.

Not sure what you mean to make sure application variable is set. Isn't it already set on the global. Now that everything seems to be set up.

When I build on that project the next version should show as 1. So does this go in the pre-build event? If so do I call the path to the version. Keep in mind, this is not a polished feature but it should be more than enough to get you started. The concept is simple though. The post-build event kicks off the console app. The console app updates the version. The parts that are missing are placing the console app in a known location and using configuration to write the file location if this is a team feature.

Also the solution increments the last value in the Version only. You'll need to modify the console app to increment the other Version parts according to your business rules. No, the console app writes the file. The post-build event uses the path to the Console app exe. I placed the exe in the web project's bin folder. OK I'm confused here. What goes in the post event? What is this console app exe. Is that something that gets created during the build? I'm just trying to figure this out.

You have to keep in mind I haven't done this before so just giving me bits and pieces isn't going to help. You will need to be more specific. I came up with this idea because you do not want to use the built-in VS feature and the versioning scheme is custom. I'm not sure what I can do for you if you feel that way. From my perspective, I've been more than specific but you ignore the advice, don't try the source code, or even read the posted links.

It seems you want someone to craft an entire solution according to your requirements. You have to put in some work as well.

Man you are incredibly difficult at times. What part of that do you not understand. You are going to have to break this down for me please. You didn't explain what exactly the console app is. Is it global. Is it something else. What goes in the build event specifically. I don't know that's why I'm asking. Telling me you are not sure what you can do for me is bs. You are choosing not to for some reason.



0コメント

  • 1000 / 1000