Comments (3)
I don't think you need to explicitly specify AssemblyVersion
and FileVersion
in .NET Core projects; I omit these assembly attributes and I find that it automatically generates an AssemblyInfo.cs
file in the obj
folder with AssemblyVersion
and FileVersion
set to whatever Version
is, which is set by dotnet-setversion
.
I've just tried this now with one of my projects.
src/PROJECT/Properties/AssemblyInfo.cs
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("...")]
[assembly: AssemblyProduct("...")]
[assembly: AssemblyTrademark("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8d58e41c-c2f2-4554-830e-4407f7b6d5ed")]
[assembly: InternalsVisibleTo("...")]
[assembly: InternalsVisibleTo("...")]
Then $dotnet setversion 1.2.3
Then $dotnet build
Then I get this output:
src/PROJECT/obj/Debug/netstandard1.4/COMPANY.PRODUCT.AssemblyInfo.cs
// Generated by the MSBuild WriteCodeFragment class.
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCopyrightAttribute("...")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("...")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.2.3.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.2.3")]
[assembly: System.Reflection.AssemblyTitleAttribute("...)]
[assembly: System.Reflection.AssemblyVersionAttribute("1.2.3.0")]
from dotnet-setversion.
Exactly what I ended up discovering. Many teams (and ours included) will oft times set FileVersion and AssemblyVersion to different things, to convey different information. For instance the fileversion might be set to reflect the state of the build, and assemblyversion set to reflect the actual version that is shipping.
Removing the attributes means they get set as you say, but as a future improvement, you might want to add the facility to set them individually. IIRC, there is also a ProductVersion attribute that is handy to set because it's a string, and you can tag your code with the actual git sha, so you have traceability back to the code. That one would be handy too.
Love this solution to the problem. Much applause deserved.
from dotnet-setversion.
Going to close this for now (housekeeping) but can re-open if this is still something you want.
from dotnet-setversion.
Related Issues (20)
- CI build hangs indefinitely HOT 4
- Error on Build HOT 2
- Support for .NET Core 3.1 HOT 2
- No problems here, just thanks
- trim trailing newline HOT 2
- Support for .NET 5.0
- Support to modify VersionPrefix and automatically increment a specified portion of the semantic version HOT 2
- Support for .NET 6.0 HOT 2
- Working with older project formats HOT 2
- Error when running HOT 4
- Support for .NET 7.0 HOT 3
- Support for .NET 8 HOT 5
- Doesn't work for dotnetcore 2.0 HOT 4
- Drop support for .NET Core 2.1, .NET Core 3.1, and .NET 5 HOT 1
- Latest dotnet2.0-sdk container doesn't work with setversion HOT 4
- Add support for the VSTS dotnet build task HOT 23
- TeamCity integration? HOT 3
- Does not handle multiple <PropertyGroup> tags HOT 1
- Unexpected behaviour in a directory with multiple csproj files HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dotnet-setversion.