Skip to content

Commit 02bbbc0

Browse files
committed
Add AssemblyInfo.Uwp.cs
Add exclude to all projects so only a single AssemblyInfo file is loaded for each. Refactor UpdateAssemblyInfo.ps1 a bit to support UWP project in same folder as main lib. Could not easily move UWP to its own folder due to losing solution dirs when including files with wildcards like this: ..\UnitsNet.Shared\**\*.cs
1 parent 3d1c175 commit 02bbbc0

File tree

5 files changed

+74
-15
lines changed

5 files changed

+74
-15
lines changed

Build/UpdateAssemblyInfo.ps1

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
.EXAMPLE
77
Set new version.
88
powershell UpdateAssemblyInfo.ps1 1.2.3.4
9-
9+
1010
.NOTES
1111
Author: Andreas Gullberg Larsen
1212
Date: May 2, 2014
@@ -40,37 +40,38 @@ function Get-VersionFromNuspec ([string] $nuspecFilePath) {
4040
}
4141

4242
#-------------------------------------------------------------------------------
43-
# Description: Sets the AssemblyVersion and AssemblyFileVersion of
43+
# Description: Sets the AssemblyVersion and AssemblyFileVersion of
4444
# AssemblyInfo.cs files.
4545
#
4646
# Author: Andreas Larsen
4747
# Version: 1.0
4848
#-------------------------------------------------------------------------------
49-
function Update-AssemblyInfoFiles ([string] $libName) {
49+
function Update-AssemblyInfoFiles ([string] $nuspecFilePath, [string] $assemblyInfoFilePath) {
5050

51-
[Version]$version = Get-VersionFromNuspec "$root\Build\$libName.nuspec"
51+
[Version]$version = Get-VersionFromNuspec "$root\$nuspecFilePath"
5252

5353
$assemblyVersionPattern = 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
5454
$fileVersionPattern = 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
5555
$assemblyVersion = 'AssemblyVersion("' + $version + '")';
5656
$fileVersion = 'AssemblyFileVersion("' + $version + '")';
57-
58-
Get-ChildItem "$root\$libName\Properties" | Where { $_.PSChildName -match "^AssemblyInfo\.cs$"} | ForEach-Object {
57+
58+
Get-ChildItem "$root\$assemblyInfoFilePath" | ForEach-Object {
5959
$filename = $_.Directory.ToString() + '\' + $_.Name
6060
$filename + ' -> ' + $version
61-
61+
6262
(Get-Content $filename -Encoding UTF8) | ForEach-Object {
6363
% {$_ -replace $assemblyVersionPattern, $assemblyVersion } |
6464
% {$_ -replace $fileVersionPattern, $fileVersion }
6565
} | Set-Content $filename -Encoding UTF8
66-
}
66+
}
6767
}
6868

6969
try {
7070
"Updating assembly info to version: $setVersion"
7171
""
72-
Update-AssemblyInfoFiles "UnitsNet"
73-
Update-AssemblyInfoFiles "UnitsNet.Serialization.JsonNet"
72+
Update-AssemblyInfoFiles "Build\UnitsNet.nuspec" "UnitsNet\Properties\AssemblyInfo.cs"
73+
Update-AssemblyInfoFiles "Build\UnitsNet.Uwp.nuspec" "UnitsNet\Properties\AssemblyInfo.Uwp.cs"
74+
Update-AssemblyInfoFiles "Build\UnitsNet.Serialization.JsonNet.nuspec" "UnitsNet.Serialization.JsonNet\Properties\AssemblyInfo.cs"
7475
}
7576
catch {
7677
$myError = $_.Exception.ToString()
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright(c) 2007 Andreas Gullberg Larsen
2+
// https://github.com/anjdreas/UnitsNet
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
using System;
23+
using System.Reflection;
24+
using System.Resources;
25+
using System.Runtime.CompilerServices;
26+
27+
#if WINDOWS_UWP
28+
using System.Runtime.InteropServices;
29+
[assembly: ComVisible(false)]
30+
#endif
31+
32+
// General Information about an assembly is controlled through the following
33+
// set of attributes. Change these attribute values to modify the information
34+
// associated with an assembly.
35+
36+
[assembly: AssemblyTitle("Units.NET")]
37+
[assembly: AssemblyDescription("Units.NET gives you all the common units of measurement and the conversions between them. It is light-weight, unit tested and supports PCL.")]
38+
[assembly: AssemblyConfiguration("")]
39+
[assembly: AssemblyCompany("Andreas Gullberg Larsen")]
40+
[assembly: AssemblyProduct("Units.NET")]
41+
[assembly: AssemblyCopyright("Copyright © 2007 Andreas Gullberg Larsen")]
42+
[assembly: AssemblyTrademark("")]
43+
[assembly: AssemblyCulture("")]
44+
[assembly: NeutralResourcesLanguage("")]
45+
[assembly: CLSCompliant(true)]
46+
// Version information for an assembly consists of the following four values:
47+
//
48+
// Major Version
49+
// Minor Version
50+
// Build Number
51+
// Revision
52+
//
53+
54+
// Give access to internal members for testing
55+
[assembly: InternalsVisibleTo("UnitsNet.Tests")]
56+
57+
[assembly: AssemblyVersion("3.30.0")]
58+
[assembly: AssemblyFileVersion("3.30.0")]

UnitsNet/UnitsNet.Net35.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@
4444
<Reference Include="System.Xml" />
4545
</ItemGroup>
4646
<ItemGroup>
47-
<Compile Include="**\*.cs;" Exclude="obj\**" />
47+
<Compile Include="**\*.cs;" Exclude="obj\**;**\*.Uwp.cs" />
4848
<None Include="packages.UnitsNet.Net35.config" />
4949
<None Include="Scripts\**\*.*" />
5050
</ItemGroup>
5151
<ItemGroup>
5252
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
5353
</ItemGroup>
5454
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
55-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
55+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
5656
Other similar extension points exist, see Microsoft.Common.targets.
5757
<Target Name="BeforeBuild">
5858
</Target>

UnitsNet/UnitsNet.Portable40.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<WarningLevel>4</WarningLevel>
4040
</PropertyGroup>
4141
<ItemGroup>
42-
<Compile Include="**\*.cs;" Exclude="obj\**" />
42+
<Compile Include="**\*.cs;" Exclude="obj\**;**\*.Uwp.cs" />
4343
<None Include="packages.UnitsNet.Portable40.config" />
4444
<None Include="Scripts\**\*.*" />
4545
</ItemGroup>
@@ -50,7 +50,7 @@
5050
</Reference>
5151
</ItemGroup>
5252
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
53-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
53+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
5454
Other similar extension points exist, see Microsoft.Common.targets.
5555
<Target Name="BeforeBuild">
5656
</Target>

UnitsNet/UnitsNet.Uwp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
<None Include="UnitsNet.Uwp.project.json" />
103103
</ItemGroup>
104104
<ItemGroup>
105-
<Compile Include="**\*.cs;" Exclude="obj\**" />
105+
<Compile Include="**\*.cs;" Exclude="obj\**;Properties\AssemblyInfo.cs" />
106106
<None Include="Scripts\**\*.*" />
107107
</ItemGroup>
108108
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">

0 commit comments

Comments
 (0)