continuous integration - Setting the version number for .NET Core projects - CSPROJ - not JSON projects -
this question similar setting version number .net core projects, not same. using latest stable version of .net core @ time of writing (1.1) , vs2017, .net core has switched json based project files csproj files.
so - trying set ci environment able modify something prior build stamp builds correct version number.
if use attributes old (sharedassemblyinfo.cs trick):
[assembly: assemblyfileversion("3.3.3.3")] [assembly: assemblyversion("4.4.4.4")]
somewhere in project, get
cs0579 - duplicate 'system.reflection.assemblyfileversionattribute'
and
cs0579 - duplicate 'system.reflection.assemblyversionattribute'
errors when building.
when digging bit, find there file looks generated during build process (it doesn't exist before build) in \obj\debug\netcoreapp1.1
:
//------------------------------------------------------------------------------ // <auto-generated> // code generated tool. // runtime version:4.0.30319.42000 // // changes file may cause incorrect behavior , lost if // code regenerated. // </auto-generated> //------------------------------------------------------------------------------ using system; using system.reflection; [assembly: system.reflection.assemblycompanyattribute("testapplication")] [assembly: system.reflection.assemblyconfigurationattribute("debug")] [assembly: system.reflection.assemblydescriptionattribute("package description")] [assembly: system.reflection.assemblyfileversionattribute("1.1.99.0")] [assembly: system.reflection.assemblyinformationalversionattribute("1.1.99")] [assembly: system.reflection.assemblyproductattribute("testapplication")] [assembly: system.reflection.assemblytitleattribute("testapplication")] [assembly: system.reflection.assemblyversionattribute("1.1.99.0")] // generated msbuild writecodefragment class.
question - how do bit?
can see must somehow generated values entered in project properties 'package page', don't know right way change these values on ci machine.
ideally, i'd able specify information in (jenkins) ci script, i'd settle being able set version number.
edit - more info
after reading first answer, wanted make clear creating both services , nuget packages - , prefer have 1 way of versioning everything, old json project update single file.
update going scripting change csproj file in opinion rather hacky section need modify looks this...
<propertygroup> <outputtype>exe</outputtype> <targetframework>netcoreapp1.1</targetframework> <version>1.0.7777.0</version> <assemblyversion>1.0.8888.0</assemblyversion> <fileversion>1.0.9999.0</fileversion> <company>mycompany</company> <authors>authorname</authors> <product>productname</product> <description /> <copyright>copyright © 2017</copyright> </propertygroup>
so - problem here there multiple 'propertygroup' elements; others appear labelled - not knowing how csproj put together, can't case.
i working on premise package details filled in, otherwise value tags (above) don't appear in xml - can use script update values in place. if value tags not there, have no clear idea propertygroup element insert values (and order, appears important; changing order stopped me loading project in vs2017).
i still holding out better solution one!
update: after marking question possible duplicate (auto versioning in visual studio 2017 (.net core)) - hadn't seen question before , reading seems same except dont want set version number. also, answers question not solve problem - asks asked in question. accepted answer question answer need solve problem - while other question came first , appears same - not me @ all. maybe mod can help?
you can override property command line passing /p:proeprtyname=value
arguments dotnet restore
, dotnet build
, dotnet pack
.
currently, version composition works this: if version
unset, use versionprefix
(defaults 1.0.0 if unset) , - if present - append versionsuffix
.
all other version defaulted whatever version
is.
so example can set <versionprefix>1.2.3</versionprefix>
in csproj , call dotnet pack --version-suffix beta1
produce yourapp.1.2.3-bea1.nupkg
(if have project reference want version suffix applied well, need call dotnet restore /p:versionsuffix=beta1
before - known bug in tooling).
of course, can use custom variables well, see this github issue few examples.
for complete reference of supported assembly attributes, suggest looking @ source code of build logic here (the values surrounded $()
properties used). , since i'm talking source, this logic composes version , few other properties.
Comments
Post a Comment