Skip to content

Commit 6d55031

Browse files
committed
NH-3927 - Switch to SemVer version generation
- SharedAssemblyInfo.?? are retired
1 parent df34f46 commit 6d55031

21 files changed

+83
-309
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ The main GitHub repository is at <https://github.com/nhibernate/nhibernate-core>
3535
## Setting up For Development
3636

3737
1. Install your favorite database and optionally set up a user capable of creating and dropping a database called **nhibernate**. There are some per-database instructions in the lib/teamcity/* folders, which you may find helpful. For SQL Server, you might be able to use the **localhost\sqlexpress** instance installed with Visual Studio. Often people already have databases set up, so you might not even need to do anything in this step.
38-
2. Run the build menu and select the option A to create the AssemblyInfo.cs files.
39-
3. Run the build menu and select option B to create a new test configuration. Notepad will pop up and you should edit the connection string information, saving it when you're done. These configurations will appear in the "available-test-configurations" folder.
40-
4. Run the build menu and select option C to activate the test configuration you created. The appropriate configuration will be copied to the "current-test-configuration" folder.
41-
5. (Optional) Run all the tests with option D and hopefully you will see no failing tests. The build may fail on certain databases; please ask on the mailing list if you are having trouble.
42-
6. Before using the database for unit tests from Visual Studio, you'll need to create an empty database that matches your connection string. [NH-2866][2] will make this easier, but for now you just have to drop/create the database specified in your connection string yourself.
38+
2. Run the build menu and select option B to create a new test configuration. Notepad will pop up and you should edit the connection string information, saving it when you're done. These configurations will appear in the "available-test-configurations" folder.
39+
3. Run the build menu and select option C to activate the test configuration you created. The appropriate configuration will be copied to the "current-test-configuration" folder.
40+
4. (Optional) Run all the tests with option D and hopefully you will see no failing tests. The build may fail on certain databases; please ask on the mailing list if you are having trouble.
41+
5. Before using the database for unit tests from Visual Studio, you'll need to create an empty database that matches your connection string. [NH-2866][2] will make this easier, but for now you just have to drop/create the database specified in your connection string yourself.
4342

4443
## Creating a Test Case to Verify the Issue
4544

ShowBuildMenu.bat

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ set NUNIT="%~dp0Tools\NUnit.ConsoleRunner.3.6.0\tools\nunit3-console.exe"
99

1010
:main-menu
1111
echo ========================= NHIBERNATE BUILD MENU ==========================
12-
echo --- SETUP ---
13-
echo A. Set up for Visual Studio (creates AssemblyInfo.cs files).
14-
echo.
1512
echo --- TESTING ---
1613
echo B. (Step 1) Set up a new test configuration for a particular database.
1714
echo C. (Step 2) Activate a test configuration.
@@ -29,16 +26,15 @@ echo --- Exit ---
2926
echo X. Make the beautiful build menu go away.
3027
echo.
3128

32-
%BUILDTOOL% prompt ABCDEFGIX
33-
if errorlevel 8 goto end
34-
if errorlevel 7 goto teamcity-menu
35-
if errorlevel 6 goto build-release-package
36-
if errorlevel 5 goto build-release
37-
if errorlevel 4 goto build-debug
38-
if errorlevel 3 goto test-run
39-
if errorlevel 2 goto test-activate
40-
if errorlevel 1 goto test-setup-menu
41-
if errorlevel 0 goto build-visual-studio
29+
%BUILDTOOL% prompt BCDEFGIX
30+
if errorlevel 7 goto end
31+
if errorlevel 6 goto teamcity-menu
32+
if errorlevel 5 goto build-release-package
33+
if errorlevel 4 goto build-release
34+
if errorlevel 3 goto build-debug
35+
if errorlevel 2 goto test-run
36+
if errorlevel 1 goto test-activate
37+
if errorlevel 0 goto test-setup-menu
4238

4339
:test-setup-menu
4440
echo A. Add a test configuration for SQL Server.
@@ -172,10 +168,6 @@ rem :build-test
172168
rem %NANT% test
173169
rem goto main-menu
174170

175-
:build-visual-studio
176-
%NANT% visual-studio
177-
goto main-menu
178-
179171
:build-debug
180172
%NANT% clean build
181173
echo.

build-common/NHibernate.props

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project>
2+
<PropertyGroup>
3+
<VersionMajor Condition="'$(VersionMajor)' == ''">5</VersionMajor>
4+
<VersionMinor Condition="'$(VersionMinor)' == ''">0</VersionMinor>
5+
<VersionPatch Condition="'$(VersionPatch)' == ''">0</VersionPatch>
6+
<VersionSuffix Condition="'$(VersionSuffix)' == ''">Alpha1</VersionSuffix>
7+
8+
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
9+
<AssemblyVersion>$(VersionMajor).$(VersionMinor).0.0</AssemblyVersion>
10+
<FileVersion>$(VersionPrefix).0</FileVersion>
11+
12+
<Product>NHibernate</Product>
13+
<Company>NHibernate.info</Company>
14+
<Copyright>Licensed under LGPL.</Copyright>
15+
</PropertyGroup>
16+
</Project>

build-common/common-project.xml

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
- common.compile-all
2929
compile a solution, generating the documentation file (.xml)
3030
31-
- common.generate-assemblyinfo
32-
generate an AssemblyInfo.cs file from assembly.* NAnt properties.
33-
3431
- common.run-tests
3532
run compiled NUnit tests.
3633
@@ -58,7 +55,7 @@
5855
</exec>
5956
</target>
6057

61-
<target name="common.compile-all" depends="common.generate-assemblyinfo common.nuget-restore">
58+
<target name="common.compile-all" depends="common.nuget-restore">
6259
<!--property name="msbuild.cmd" value="${cmd.sln} ${cmd.out} ${cmd.platform} ${cmd.debug} ${cmd.optimize} ${cmd.doc} /t:Rebuild /v:q /m" /-->
6360
<exec program="${path::combine(tools.dir, 'msbuild.cmd')}" verbose="true">
6461
<arg value="${root.dir}/src/NHibernate.sln" />
@@ -72,42 +69,6 @@
7269
<arg value="/m" />
7370
</exec>
7471
</target>
75-
76-
<target name="common.set-assembly-attribute-values">
77-
<property overwrite="false" name="assembly.version" value="${project.default-assembly-version}" />
78-
<property overwrite="false" name="assembly.version.informational" value="${project.version}" />
79-
<property overwrite="false" name="assembly.version.file" value="${project.version.numeric}" />
80-
</target>
81-
82-
<target name="common.generate-assemblyinfo"
83-
depends="common.init common.set-assembly-attribute-values"
84-
description="Generate SharedAssemblyInfo.* using assembly.* properties."
85-
>
86-
<asminfo output="${root.dir}/src/SharedAssemblyInfo.cs" language="CSharp">
87-
<imports>
88-
<import namespace="System" />
89-
<import namespace="System.Reflection" />
90-
<import namespace="System.Runtime.CompilerServices" />
91-
</imports>
92-
<attributes>
93-
<attribute type="AssemblyVersionAttribute" value="${assembly.version}" />
94-
<attribute type="AssemblyInformationalVersionAttribute" value="${assembly.version.informational}" />
95-
<attribute type="AssemblyFileVersionAttribute" value="${assembly.version.file}" />
96-
</attributes>
97-
</asminfo>
98-
<asminfo output="${root.dir}/src/SharedAssemblyInfo.vb" language="VB">
99-
<imports>
100-
<import namespace="System" />
101-
<import namespace="System.Reflection" />
102-
<import namespace="System.Runtime.CompilerServices" />
103-
</imports>
104-
<attributes>
105-
<attribute type="AssemblyVersionAttribute" value="${assembly.version}" />
106-
<attribute type="AssemblyInformationalVersionAttribute" value="${assembly.version.informational}" />
107-
<attribute type="AssemblyFileVersionAttribute" value="${assembly.version.file}" />
108-
</attributes>
109-
</asminfo>
110-
</target>
11172

11273
<target name="common.run-tests"
11374
description="Run NUnit tests">

build-common/common.xml

Lines changed: 3 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -32,116 +32,10 @@
3232
<property name="lib.dir" value="lib" dynamic="true" />
3333
<property name="lib.family.dir" value="${path::combine(lib.dir, framework::get-family(framework::get-target-framework()))}" dynamic="true" />
3434
<property name="lib.framework.dir" value="${path::combine(lib.family.dir, version::to-string(framework::get-version()))}" dynamic="true" />
35-
36-
<!--
37-
These are used to set the correct attributes in AssemblyInfo.cs.
38-
-->
39-
<property name="project.company" value="NHibernate.org" />
40-
41-
<!--
42-
Version number computation
43-
44-
JBoss product versioning guidelines (http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossProductVersioning)
45-
say we are supposed to use version numbers formatted like major.minor.patch.qualifier, where
46-
qualifier is alphanumeric (Alpha#, Beta#, CR#, GA, SP#), and the numeric part may be anything, e.g.
47-
a time/date stamp, a SVN revision number and so on.
48-
49-
I'm only going to use simple sequential numbers for now and the script below is used to translate
50-
the alphanumeric version into a numeric assembly version: x.y.z.qN is translated into x.y.z.(base+N)
51-
where base is 1000 for Alpha, 2000 for Beta, 3000 for CR, and 4000 for both GA and SP (so GA is
52-
effectively SP0).
53-
-->
54-
55-
<property name="project.version" value="5.0.0.Alpha1" overwrite="false" />
56-
57-
<!-- This version number should be changed if, but only if, there are incompatible
58-
changes compared to the previous version. -->
59-
<property name="project.default-assembly-version" value="5.0.0.1001" overwrite="false" />
60-
61-
<!-- Compute short project version (major.minor) using a regex -->
62-
<regex input="${project.version}" pattern="^(?'shortversion'\d+\.\d+)" />
63-
64-
<property name="project.version.short" value="${shortversion}" />
65-
66-
<!-- Compute and set project.version.numeric and project.version.nuget from project.version if it hasn't been set already -->
67-
<if test="${not property::exists('project.version.numeric')}">
68-
69-
<script language="C#">
70-
<references>
71-
<include name="System.dll" />
72-
</references>
73-
<imports>
74-
<import namespace="System.Text.RegularExpressions" />
75-
</imports>
76-
<code><![CDATA[
77-
public const string VersionRegex = @"^(?<major>.+)\.{1}(?<minor>.+)\.{1}(?<build>.+)\.{1}(?<qualifier>Alpha|Beta|CR|GA|SP*)(?<qualifierNumber>\d*)$";
78-
79-
public static void ScriptMain(Project project)
80-
{
81-
string version = project.Properties["project.version"];
82-
project.Properties["project.version.numeric"] = ToNumericVersion(version);
83-
project.Properties["project.version.nuget"] = ToNuGetVersion(version);
84-
}
85-
86-
public static string ToNuGetVersion(string version)
87-
{
88-
Match matches = Regex.Match(version, VersionRegex, RegexOptions.Singleline);
89-
if (matches.Success == false) throw new BuildException("Unrecognised version number.");
90-
if (matches.Groups.Count < 4) throw new BuildException("Unrecognised version number.");
91-
92-
string qualifier = matches.Groups["qualifier"].Value;
93-
94-
// For official releases we must use a completely numeric version.
95-
// For pre-releases, the alphanumerics should be retained, to make Nuget
96-
// understand it's a pre-release.
97-
if (qualifier == "GA") return ToNumericVersion(version);
98-
if (qualifier == "SP") return ToNumericVersion(version);
99-
100-
return String.Concat(
101-
String.Join(".", new string[] { matches.Groups["major"].Value, matches.Groups["minor"].Value, matches.Groups["build"].Value }),
102-
"-",
103-
matches.Groups["qualifier"].Value,
104-
matches.Groups["qualifierNumber"].Value);
105-
}
106-
107-
public static string ToNumericVersion(string version)
108-
{
109-
const int BaseAlpha = 1000;
110-
const int BaseBeta = 2000;
111-
const int BaseCR = 3000;
112-
const int BaseGA = 4000;
113-
const int BaseSP = 4000; // SP is same as GA because GA has no number and SP's start with 1.
114-
115-
Match matches = Regex.Match(version, VersionRegex);
116-
if (matches.Success == false) throw new BuildException("Unrecognised version number.");
117-
if (matches.Groups.Count < 4) throw new BuildException("Unrecognised version number.");
118-
119-
string qualifier = matches.Groups["qualifier"].Value;
120-
int qualifierNumber;
121-
Int32.TryParse(matches.Groups["qualifierNumber"].Value, out qualifierNumber);
122-
int revisionBase;
123-
124-
switch (qualifier)
125-
{
126-
case "Alpha": revisionBase = BaseAlpha; break;
127-
case "Beta": revisionBase = BaseBeta; break;
128-
case "CR": revisionBase = BaseCR; break;
129-
case "GA": revisionBase = BaseGA; break;
130-
case "SP": revisionBase = BaseSP; break;
131-
default: throw new BuildException("Unknown version qualifier " + qualifier);
132-
}
133-
134-
int revisionNumber = revisionBase + qualifierNumber;
13535

136-
return String.Join(".", new string[] {
137-
matches.Groups["major"].Value,
138-
matches.Groups["minor"].Value,
139-
matches.Groups["build"].Value,
140-
revisionNumber.ToString() });
141-
}
142-
]]></code>
143-
</script>
144-
</if>
36+
<!-- This is used only for build folder -->
37+
<!-- TODO: Either remove or refactor to use NHibernate.props -->
38+
<property name="project.version" value="5.0.0-Alpha1" overwrite="false" />
14539

14640
<!-- debug|release -->
14741
<property name="build.defines" value="" />

default.build

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@
138138
<exclude name="**/obj/**" />
139139
</fileset>
140140
</copy>
141-
142-
<!-- Generate AssemblyInfo.cs files for Visual Studio -->
143-
<nant buildfile="${source.tmpdir}/default.build" target="visual-studio" />
144-
145141
</target>
146142

147143
<target name="sources-zip" depends="init sources">
@@ -224,9 +220,6 @@
224220
<echo message="Created a '${project.config}' package in ${build.dir}" />
225221
</target>
226222

227-
<target name="visual-studio" depends="init common.init common.generate-assemblyinfo" description="Generates SharedAssemblyInfo.cs files to work with Visual Studio">
228-
</target>
229-
230223
<target name="cleanall" description="Deletes every build configuration">
231224
<echo message="Deleting all builds from all configurations" />
232225
<delete dir="build" failonerror="false" />
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
using System;
22
using System.Reflection;
33

4-
[assembly: CLSCompliantAttribute(false)]
5-
[assembly: AssemblyTitleAttribute("NHibernate.DomainModel")]
6-
[assembly: AssemblyDescriptionAttribute("The Domain Model used by the Unit Tests.")]
7-
[assembly: AssemblyCompanyAttribute("NHibernate.info")]
8-
[assembly: AssemblyProductAttribute("NHibernate.DomainModel")]
9-
[assembly: AssemblyCopyrightAttribute("Licensed under LGPL.")]
10-
[assembly: AssemblyDelaySignAttribute(false)]
11-
4+
[assembly: CLSCompliant(false)]
5+
[assembly: AssemblyDelaySign(false)]

src/NHibernate.DomainModel/NHibernate.DomainModel.csproj

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<Import Project="../../build-common/NHibernate.props" />
23

34
<PropertyGroup>
5+
<Description>The Domain Model used by the Unit Tests.</Description>
6+
47
<TargetFramework>net461</TargetFramework>
5-
<GenerateAssemblyTitleAttribute>False</GenerateAssemblyTitleAttribute>
6-
<GenerateAssemblyProductAttribute>False</GenerateAssemblyProductAttribute>
7-
<GenerateAssemblyCompanyAttribute>False</GenerateAssemblyCompanyAttribute>
8-
<GenerateAssemblyDescriptionAttribute>False</GenerateAssemblyDescriptionAttribute>
9-
<GenerateAssemblyVersionAttribute>False</GenerateAssemblyVersionAttribute>
10-
<GenerateAssemblyFileVersionAttribute>False</GenerateAssemblyFileVersionAttribute>
11-
<GenerateAssemblyInformationalVersionAttribute>False</GenerateAssemblyInformationalVersionAttribute>
128
<NoWarn>$(NoWarn);3001;3002;3003;3005</NoWarn>
139
</PropertyGroup>
1410

@@ -25,10 +21,6 @@
2521
<EmbeddedResource Include="**\*.hbm.xml" />
2622
</ItemGroup>
2723

28-
<ItemGroup>
29-
<Compile Include="..\SharedAssemblyInfo.cs" Link="SharedAssemblyInfo.cs" />
30-
</ItemGroup>
31-
3224
<ItemGroup>
3325
<PackageReference Include="Iesi.Collections" Version="4.0.2" />
3426
</ItemGroup>

src/NHibernate.Everything.sln

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
44
VisualStudioVersion = 15.0.26730.3
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Support", "Support", "{9BDB5C84-14EC-4384-B423-9E319675B3CA}"
7+
ProjectSection(SolutionItems) = preProject
8+
..\build-common\NHibernate.props = ..\build-common\NHibernate.props
9+
EndProjectSection
710
ProjectSection(FolderStartupServices) = postProject
811
{B4F97281-0DBD-4835-9ED8-7DFB966E87FF} = {B4F97281-0DBD-4835-9ED8-7DFB966E87FF}
912
EndProjectSection
@@ -68,11 +71,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHibernate.Tool.HbmXsd", "N
6871
EndProject
6972
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "NHibernate.Test.VisualBasic", "NHibernate.Test.VisualBasic\NHibernate.Test.VisualBasic.vbproj", "{7C2EF610-BCA0-4D1F-898A-DE9908E4970C}"
7073
EndProject
71-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AssemblyInfo", "AssemblyInfo", "{00C03FBC-6720-4917-A203-DEA12FF3C7BF}"
72-
ProjectSection(SolutionItems) = preProject
73-
SharedAssemblyInfo.cs = SharedAssemblyInfo.cs
74-
EndProjectSection
75-
EndProject
7674
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHibernate.Example.Web", "NHibernate.Example.Web\NHibernate.Example.Web.csproj", "{B291C1C1-599B-418E-8591-8A8CF1CAA188}"
7775
EndProject
7876
Global
@@ -161,7 +159,6 @@ Global
161159
{7AEE5B37-C552-4E59-9B6F-88755BCB5070} = {094F74CD-2DD7-496F-BC48-A6D357BF33FD}
162160
{446E148D-A9D5-4D7D-A706-BEDD45B2BC7D} = {92509065-DAEA-4457-8300-C7B64CD0E9F4}
163161
{7C2EF610-BCA0-4D1F-898A-DE9908E4970C} = {094F74CD-2DD7-496F-BC48-A6D357BF33FD}
164-
{00C03FBC-6720-4917-A203-DEA12FF3C7BF} = {9BDB5C84-14EC-4384-B423-9E319675B3CA}
165162
EndGlobalSection
166163
GlobalSection(ExtensibilityGlobals) = postSolution
167164
SolutionGuid = {A41913C2-EDEB-440A-BBDE-0AEB56C1CBA6}
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
Imports System
2-
Imports System.Reflection
1+
Imports System.Reflection
32
Imports NUnit.Framework
43

54
<Assembly: CLSCompliant(False)>
6-
<Assembly: AssemblyTitle("NHibernate.Test.VisualBasic")>
7-
<Assembly: AssemblyDescription("The Visual Basic Unit Tests for NHibernate.")>
8-
<Assembly: AssemblyCompany("NHibernate.info")>
9-
<Assembly: AssemblyProduct("NHibernate.Test.VisualBasic")>
10-
<Assembly: AssemblyCopyright("Licensed under LGPL.")>
11-
<Assembly: AssemblyTrademark("")>
125
<Assembly: AssemblyDelaySign(False)>
13-
146
<Assembly: LevelOfParallelism(0)>
15-

0 commit comments

Comments
 (0)