Skip to content

Commit 4bd194b

Browse files
committed
remove namespace from generated version
too hard to determine a valid name and didnt add any real value
1 parent c47337a commit 4bd194b

6 files changed

+71
-86
lines changed

AcceptanceTests/AcceptanceTests.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
<EmbeddedResource Include="Properties\Resources.resx">
9292
<Generator>ResXFileCodeGenerator</Generator>
9393
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
94+
<SubType>Designer</SubType>
9495
</EmbeddedResource>
9596
</ItemGroup>
9697
<ItemGroup>

GitVersionTask/AssemblyInfoBuilder.cs

+28-35
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44

55
public class AssemblyInfoBuilder
66
{
7-
87
public VersionAndBranchAndDate VersionAndBranch;
98
public bool SignAssembly;
10-
public string AssemblyName;
11-
129
public string GetAssemblyInfoText()
1310
{
1411
var assemblyInfo = string.Format(@"
@@ -18,49 +15,45 @@ public string GetAssemblyInfoText()
1815
[assembly: AssemblyVersion(""{0}"")]
1916
[assembly: AssemblyFileVersion(""{1}"")]
2017
[assembly: AssemblyInformationalVersion(""{2}"")]
21-
[assembly: {4}.NugetVersion(""{3}"")]
22-
[assembly: {4}.ReleaseDate(""{6}"", ""{7}"")]
18+
[assembly: NugetVersion(""{3}"")]
19+
[assembly: ReleaseDate(""{5}"", ""{6}"")]
2320
24-
namespace {4}
21+
[System.Runtime.CompilerServices.CompilerGenerated]
22+
class NugetVersionAttribute : Attribute
2523
{{
26-
[System.Runtime.CompilerServices.CompilerGenerated]
27-
class NugetVersionAttribute : Attribute
24+
public NugetVersionAttribute(string version)
2825
{{
29-
public NugetVersionAttribute(string version)
30-
{{
31-
Version = version;
32-
}}
33-
34-
public string Version{{get;set;}}
26+
Version = version;
3527
}}
3628
37-
[System.Runtime.CompilerServices.CompilerGenerated]
38-
class ReleaseDateAttribute : System.Attribute
39-
{{
40-
public string OriginalDate {{ get; private set; }}
41-
public string Date {{ get; private set; }}
42-
43-
public ReleaseDateAttribute(string originalDate, string date)
44-
{{
45-
OriginalDate = date;
46-
Date = date;
47-
}}
48-
}}
29+
public string Version{{get;set;}}
4930
}}
50-
namespace {4}
31+
32+
[System.Runtime.CompilerServices.CompilerGenerated]
33+
class ReleaseDateAttribute : System.Attribute
5134
{{
52-
[System.Runtime.CompilerServices.CompilerGenerated]
53-
static class GitVersionInformation
35+
public string OriginalDate {{ get; private set; }}
36+
public string Date {{ get; private set; }}
37+
38+
public ReleaseDateAttribute(string originalDate, string date)
5439
{{
55-
public static string AssemblyVersion = ""{0}"";
56-
public static string AssemblyFileVersion = ""{1}"";
57-
public static string AssemblyInformationalVersion = ""{2}"";
58-
public static string NugetVersion = ""{3}"";
59-
public static string SemVer = ""{5}"";
40+
OriginalDate = date;
41+
Date = date;
6042
}}
6143
}}
6244
63-
", GetAssemblyVersion(), GetAssemblyFileVersion(), VersionAndBranch.ToLongString(), VersionAndBranch.GenerateNugetVersion(), AssemblyName, VersionAndBranch.GenerateSemVer(),
45+
[System.Runtime.CompilerServices.CompilerGenerated]
46+
static class GitVersionInformation
47+
{{
48+
public static string AssemblyVersion = ""{0}"";
49+
public static string AssemblyFileVersion = ""{1}"";
50+
public static string AssemblyInformationalVersion = ""{2}"";
51+
public static string NugetVersion = ""{3}"";
52+
public static string SemVer = ""{4}"";
53+
}}
54+
55+
56+
", GetAssemblyVersion(), GetAssemblyFileVersion(), VersionAndBranch.ToLongString(), VersionAndBranch.GenerateNugetVersion(), VersionAndBranch.GenerateSemVer(),
6457
VersionAndBranch.ReleaseDate.OriginalDate.UtcDateTime.ToString("yyyy-MM-dd"), VersionAndBranch.ReleaseDate.Date.UtcDateTime.ToString("yyyy-MM-dd"));
6558

6659
return assemblyInfo;

GitVersionTask/NugetAssets/GitVersionTask.targets

+13-14
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,19 @@
1616
<WriteVersionInfoToBuildLog
1717
SolutionDirectory="$(SolutionDir)"
1818
/>
19-
<UpdateAssemblyInfo
20-
SolutionDirectory="$(SolutionDir)"
21-
AssemblyName="$(AssemblyName)"
22-
ProjectFile="$(ProjectPath)"
23-
SignAssembly="$(SignAssembly)"
24-
CompileFiles ="@(Compile)">
25-
<Output
26-
TaskParameter="AssemblyInfoTempFilePath"
27-
PropertyName="AssemblyInfoTempFilePath" />
28-
</UpdateAssemblyInfo>
29-
30-
<ItemGroup>
31-
<Compile Include="$(AssemblyInfoTempFilePath)" />
32-
</ItemGroup>
19+
<UpdateAssemblyInfo
20+
SolutionDirectory="$(SolutionDir)"
21+
ProjectFile="$(ProjectPath)"
22+
SignAssembly="$(SignAssembly)"
23+
CompileFiles ="@(Compile)">
24+
<Output
25+
TaskParameter="AssemblyInfoTempFilePath"
26+
PropertyName="AssemblyInfoTempFilePath" />
27+
</UpdateAssemblyInfo>
28+
29+
<ItemGroup>
30+
<Compile Include="$(AssemblyInfoTempFilePath)" />
31+
</ItemGroup>
3332
</Target>
3433

3534
<!--Support for ncrunch-->

GitVersionTask/UpdateAssemblyInfo.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ public class UpdateAssemblyInfo : Task
1818
[Required]
1919
public string ProjectFile { get; set; }
2020
[Required]
21-
public string AssemblyName { get; set; }
22-
[Required]
2321
public ITaskItem[] CompileFiles { get; set; }
2422

2523
[Output]
@@ -80,8 +78,7 @@ void CreateTempAssemblyInfo(VersionAndBranchAndDate versionAndBranch)
8078
var assemblyInfoBuilder = new AssemblyInfoBuilder
8179
{
8280
VersionAndBranch = versionAndBranch,
83-
SignAssembly = SignAssembly,
84-
AssemblyName = AssemblyName
81+
SignAssembly = SignAssembly
8582
};
8683
var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText();
8784

Tests/AssemblyInfoBuilderTests.VerifyCreatedCode.approved.txt

+27-31
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,41 @@ using System.Reflection;
55
[assembly: AssemblyVersion("1.2.3")]
66
[assembly: AssemblyFileVersion("1.2.3")]
77
[assembly: AssemblyInformationalVersion("1.2.3-unstable.feature-a682956d Branch:'feature1' Sha:'a682956dc1a2752aa24597a0f5cd939f93614509'")]
8-
[assembly: MyAssembly.NugetVersion("1.2.3-Feature-feature1-a682956dc1a2752aa24597a0f5cd939f93614509")]
9-
[assembly: MyAssembly.ReleaseDate("2014-03-01", "2014-03-06")]
8+
[assembly: NugetVersion("1.2.3-Feature-feature1-a682956dc1a2752aa24597a0f5cd939f93614509")]
9+
[assembly: ReleaseDate("2014-03-01", "2014-03-06")]
1010

11-
namespace MyAssembly
11+
[System.Runtime.CompilerServices.CompilerGenerated]
12+
class NugetVersionAttribute : Attribute
1213
{
13-
[System.Runtime.CompilerServices.CompilerGenerated]
14-
class NugetVersionAttribute : Attribute
14+
public NugetVersionAttribute(string version)
1515
{
16-
public NugetVersionAttribute(string version)
17-
{
18-
Version = version;
19-
}
20-
21-
public string Version{get;set;}
16+
Version = version;
2217
}
2318

24-
[System.Runtime.CompilerServices.CompilerGenerated]
25-
class ReleaseDateAttribute : System.Attribute
26-
{
27-
public string OriginalDate { get; private set; }
28-
public string Date { get; private set; }
29-
30-
public ReleaseDateAttribute(string originalDate, string date)
31-
{
32-
OriginalDate = date;
33-
Date = date;
34-
}
35-
}
19+
public string Version{get;set;}
3620
}
37-
namespace MyAssembly
21+
22+
[System.Runtime.CompilerServices.CompilerGenerated]
23+
class ReleaseDateAttribute : System.Attribute
3824
{
39-
[System.Runtime.CompilerServices.CompilerGenerated]
40-
static class GitVersionInformation
25+
public string OriginalDate { get; private set; }
26+
public string Date { get; private set; }
27+
28+
public ReleaseDateAttribute(string originalDate, string date)
4129
{
42-
public static string AssemblyVersion = "1.2.3";
43-
public static string AssemblyFileVersion = "1.2.3";
44-
public static string AssemblyInformationalVersion = "1.2.3-unstable.feature-a682956d Branch:'feature1' Sha:'a682956dc1a2752aa24597a0f5cd939f93614509'";
45-
public static string NugetVersion = "1.2.3-Feature-feature1-a682956dc1a2752aa24597a0f5cd939f93614509";
46-
public static string SemVer = "1.2.3-Feature-feature1-a682956dc1a2752aa24597a0f5cd939f93614509";
30+
OriginalDate = date;
31+
Date = date;
4732
}
4833
}
4934

35+
[System.Runtime.CompilerServices.CompilerGenerated]
36+
static class GitVersionInformation
37+
{
38+
public static string AssemblyVersion = "1.2.3";
39+
public static string AssemblyFileVersion = "1.2.3";
40+
public static string AssemblyInformationalVersion = "1.2.3-unstable.feature-a682956d Branch:'feature1' Sha:'a682956dc1a2752aa24597a0f5cd939f93614509'";
41+
public static string NugetVersion = "1.2.3-Feature-feature1-a682956dc1a2752aa24597a0f5cd939f93614509";
42+
public static string SemVer = "1.2.3-Feature-feature1-a682956dc1a2752aa24597a0f5cd939f93614509";
43+
}
44+
45+

Tests/AssemblyInfoBuilderTests.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ public void VerifyCreatedCode()
3636
};
3737
var assemblyInfoBuilder = new AssemblyInfoBuilder
3838
{
39-
VersionAndBranch = semanticVersion,
40-
AssemblyName = "MyAssembly"
39+
VersionAndBranch = semanticVersion
4140
};
4241
var assemblyInfoText = assemblyInfoBuilder.GetAssemblyInfoText();
4342
Approvals.Verify(assemblyInfoText);

0 commit comments

Comments
 (0)