Skip to content

Commit 0342df7

Browse files
committed
Clean code + update build.cake
1 parent a52d447 commit 0342df7

File tree

94 files changed

+15061
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+15061
-480
lines changed

.appveyor.yml

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
# AppVeyor documentation https://www.appveyor.com/docs
2+
platform:
3+
- Any CPU
4+
5+
configuration:
6+
- Release
7+
8+
assembly_info:
9+
patch: false
10+
111
# Build script
212
version: '{build}'
313
image: Previous Visual Studio 2017
414
os: Previous Visual Studio 2017
15+
16+
# branches to build
517
branches:
18+
# whitelist
619
only:
7-
- master
20+
- master
21+
- dev
22+
823
clone_depth: 1
924
environment:
1025
global:
@@ -35,6 +50,9 @@ install:
3550
- ps: Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory($tempFileCurrent, $env:DOTNET_INSTALL_DIR)
3651
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
3752

53+
#---------------------------------#
54+
# build configuration #
55+
#---------------------------------#
3856
before_build:
3957
# Display .NET Core version
4058
- cmd: dotnet --version
@@ -49,8 +67,42 @@ after_build:
4967
on_finish :
5068
# any cleanup in here
5169

52-
test: 'off'
53-
deploy: 'off'
70+
#---------------------------------#
71+
# tests configuration #
72+
#---------------------------------#
73+
74+
test: off
75+
76+
#---------------------------------#
77+
# artifacts configuration #
78+
#---------------------------------#
79+
80+
artifacts:
81+
- path: 'artifacts\Nugets\**\*.nupkg'
82+
- path: 'build\**\*.zip'
83+
84+
#---------------------------------#
85+
# deployment configuration #
86+
#---------------------------------#
87+
88+
deploy:
89+
- provider: GitHub
90+
auth_token:
91+
secure: xxx
92+
artifact: /.*\.zip/
93+
draft: true
94+
on:
95+
appveyor_repo_tag: true
96+
97+
- provider: NuGet
98+
api_key:
99+
secure: xxx
100+
on:
101+
appveyor_repo_tag: true
102+
103+
#---------------------------------#
104+
# cache configuration #
105+
#---------------------------------#
54106

55107
cache:
56108
- tools -> build.cake

CodeAnalysis.ruleset

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@
7373
<Rule Id="IDE1006" Action="None" />
7474
</Rules>
7575
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
76-
<Rule Id="SA0001" Action="None" />
77-
<Rule Id="SA1101" Action="None" />
78-
<Rule Id="SA1305" Action="None" />
79-
<Rule Id="SA1412" Action="None" />
80-
<Rule Id="SA1600" Action="None" />
81-
<Rule Id="SA1609" Action="None" />
82-
<Rule Id="SA1633" Action="None" />
83-
<Rule Id="SA1652" Action="None" />
76+
<Rule Id="SA0001" Action="Hidden" />
77+
<Rule Id="SA1101" Action="Hidden" />
78+
<Rule Id="SA1305" Action="Hidden" />
79+
<Rule Id="SA1412" Action="Hidden" />
80+
<Rule Id="SA1600" Action="Hidden" />
81+
<Rule Id="SA1609" Action="Hidden" />
82+
<Rule Id="SA1633" Action="Hidden" />
83+
<Rule Id="SA1652" Action="Hidden" />
8484
</Rules>
8585
</RuleSet>

Directory.Build.props

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1-
<Project>
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
33
<TargetFramework>netcoreapp2.1</TargetFramework>
44
</PropertyGroup>
5+
<!-- Framework constants -->
56
<!--<PropertyGroup>
67
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">2.0.0</NetStandardImplicitPackageVersion>
78
</PropertyGroup>-->
8-
<!-- Framework constants -->
9-
10-
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
11-
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
12-
<DebugType>portable</DebugType>
13-
</PropertyGroup>
9+
<!--<DefineConstants>$(DefineConstants);NETCORE;NETCOREAPP2_1;LIBLOG_PORTABLE</DefineConstants>-->
1410
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
15-
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
16-
<DebugType>portable</DebugType>
11+
<DefineConstants>LIBLOG_PORTABLE</DefineConstants>
1712
</PropertyGroup>
1813

1914
<PropertyGroup>
@@ -29,7 +24,7 @@
2924
<XunitAnalyzersVersion>0.8.0</XunitAnalyzersVersion>
3025
</PropertyGroup>
3126

32-
<ItemGroup>
27+
<!--<ItemGroup>
3328
<PackageReference Include="Microsoft.AspNetCore.App" Version="$(AspNetCoreVersion)" />
3429
<PackageReference Include="Serilog" Version="2.6.0" />
3530
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.0" />
@@ -40,7 +35,7 @@
4035
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
4136
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
4237
<PackageReference Include="Serilog.Sinks.Literate" Version="3.0.0" />
43-
</ItemGroup>
38+
</ItemGroup>-->
4439

4540
<!--<PropertyGroup>
4641
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>

Directory.CodeAnalysis.props

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
<Project>
22

3-
<ItemGroup>
4-
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
3+
<!--<ItemGroup>
4+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta007">
55
<PrivateAssets>All</PrivateAssets>
66
</PackageReference>
7-
</ItemGroup>
7+
</ItemGroup>-->
88

99
<PropertyGroup>
1010
<CodeAnalysisRuleSet>$(SolutionDir)\CodeAnalysis.ruleset</CodeAnalysisRuleSet>
11+
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
1112
<Features>IOperation</Features>
12-
<NoWarn>1701;1702;1705</NoWarn>
13+
<NoWarn>$(NoWarn);1701;1702;1705;1101;1633</NoWarn>
14+
<!--<NoWarn>$(NoWarn),1573,1591,1712</NoWarn>-->
1315
<RunCodeAnalysis>false</RunCodeAnalysis>
14-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
16+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
1517
<WarningsAsErrors />
1618
<TreatSpecificWarningsAsErrors />
1719
</PropertyGroup>
1820

1921
<ItemGroup>
22+
<AdditionalFiles Include="$(SolutionDir)\CodeAnalysis.ruleset" Link="CodeAnalysis.ruleset" />
2023
<AdditionalFiles Include="$(SolutionDir)\Stylecop.json" Link="Stylecop.json" />
2124
<AdditionalFiles Include="$(SolutionDir)\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
2225
</ItemGroup>

GlobalSuppressions.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-

1+

2+
using System.Diagnostics.CodeAnalysis;
3+
4+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:File must have header", Justification = "Pending")]
5+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1652:Enable XML documentation output", Justification = "Pending")]
6+
7+
8+
9+
[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "Pending")]
10+
[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1124:Do not use regions", Justification = "Pending")]

Stylecop.json

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
3-
"settings": {
4-
"documentationRules": {
5-
"companyName": "PuzzleCMS",
6-
"copyrightText": "Copyright (c) {companyName}. All Rights Reserved.\r\nLicensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.",
7-
"xmlHeader": false,
8-
"fileNamingConvention": "metadata"
9-
},
10-
"layoutRules": {
11-
"newlineAtEndOfFile": "require"
12-
}
2+
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
3+
"settings": {
4+
"documentationRules": {
5+
"companyName": "PuzzleCMS",
6+
"copyrightText": "Copyright (c) {companyName}, mycompany.com, inc. All Rights Reserved.\r\n. See LICENSE in the project root for license information.",
7+
"documentExposedElements": false,
8+
"documentInterfaces": false,
9+
"documentInternalElements": false,
10+
"xmlHeader": true,
11+
"fileNamingConvention": "metadata"
12+
},
13+
"layoutRules": {
14+
"newlineAtEndOfFile": "require"
1315
}
14-
}
16+
}
17+
}

build.cake

Lines changed: 13 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#tool nuget:?package=xunit.runner.console&version=2.3.1
32
#tool nuget:?package=xunit.runner.visualstudio&version=2.3.1
43
#tool nuget:?package=OpenCover&version=4.6.519
@@ -19,36 +18,37 @@ var configuration =
1918
HasArgument("Configuration") ? Argument<string>("Configuration") :
2019
EnvironmentVariable("Configuration") != null ? EnvironmentVariable("Configuration") : "Release";
2120

21+
var parameters = BuildParameters.GetParameters(Context,target,configuration);
22+
var paths = BuildPaths.GetPaths(Context, parameters);
23+
2224
// The build number to use in the version number of the built NuGet packages.
2325
// There are multiple ways this value can be passed, this is a common pattern.
2426
// 1. If command line parameter parameter passed, use that.
2527
// 2. Otherwise if running on AppVeyor, get it's build number.
2628
// 3. Otherwise if running on Travis CI, get it's build number.
2729
// 4. Otherwise if an Environment variable exists, use that.
2830
// 5. Otherwise default the build number to 0.
31+
BuildVersion buildVersion=ReadVersionNumberFromProject(Context,paths.Files.VersionFile);
32+
var tempVersionSuffix = buildVersion.VersionSuffix;
33+
2934
var preReleaseSuffix =
3035
HasArgument("PreReleaseSuffix") ? Argument<string>("PreReleaseSuffix") :
3136
(AppVeyor.IsRunningOnAppVeyor && AppVeyor.Environment.Repository.Tag.IsTag) ? null :
3237
EnvironmentVariable("PreReleaseSuffix") != null ? EnvironmentVariable("PreReleaseSuffix") :
33-
"beta";
38+
tempVersionSuffix;
3439
var buildNumber = HasArgument("BuildNumber") ?
3540
Argument<int>("BuildNumber") :
3641
AppVeyor.IsRunningOnAppVeyor ? AppVeyor.Environment.Build.Number :
3742
EnvironmentVariable("BuildNumber") != null ? int.Parse(EnvironmentVariable("BuildNumber")) :
3843
0;
3944

40-
var parameters = BuildParameters.GetParameters(Context,target,configuration);
41-
var paths = BuildPaths.GetPaths(Context, parameters);
42-
43-
BuildVersion buildVersion=ReadVersionNumberFromProject(Context,paths.Files.VersionFile);
44-
var revision = buildNumber.ToString("D4");
45-
var versionElement = string.IsNullOrEmpty(preReleaseSuffix) ? null : $"-{preReleaseSuffix}-{revision}";
4645

4746
var finalVersionPrefix = buildVersion.VersionPrefix;
48-
var finalVersionSuffix = buildVersion.VersionSuffix.Replace("-*", versionElement);
47+
var finalVersionSuffix = string.IsNullOrEmpty(preReleaseSuffix) ? null :$"-{preReleaseSuffix}-{buildNumber.ToString("D4")}";
4948

5049
var finalVersion= $"{finalVersionPrefix}{finalVersionSuffix}";
5150

51+
5252
var msBuildSettings = new DotNetCoreMSBuildSettings()
5353
.WithProperty("Version", finalVersion)
5454
.WithProperty("AssemblyVersion",finalVersionPrefix)
@@ -114,6 +114,7 @@ Task("Clean")
114114
Task("NuGet-Restore")
115115
.IsDependentOn("Clean")
116116
.Does(() =>NuGetRestore(paths.Files.Solution.ToString()));
117+
117118
// NuGet restore packages for .NET Core projects only
118119
Task("DotNet-Core-Package-Restore")
119120
.IsDependentOn("NuGet-Restore")
@@ -124,17 +125,7 @@ Task("DotNet-Core-Package-Restore")
124125
Verbosity = DotNetCoreVerbosity.Minimal,
125126
});
126127
});
127-
/*
128-
Task("Create-Version-Info").Does(() =>
129-
{
130-
CreateAssemblyInfo(File("AssemblyVersionInfo.cs"), new AssemblyInfoSettings
131-
{
132-
Version = parameters.AssemblyVersion,
133-
FileVersion = parameters.Version,
134-
InformationalVersion = parameters.FullVersion
135-
});
136-
});
137-
*/
128+
138129
Task("Build")
139130
.Does(() =>DotNetCoreBuild(paths.Files.Solution.ToString(), dotNetCoreBuildSettings));
140131
// Look under a 'Tests' folder and run dotnet test against all of those projects.
@@ -171,7 +162,7 @@ Task("Test-OpenCover")
171162
.WithFilter("+[*]* -[*.UnitsTests]*")
172163
.WithFilter("-[xunit.*]*")
173164
.WithFilter("-[*.*Tests]*")
174-
//.ExcludeByAttribute("*.ExcludeFromCodeCoverage*")
165+
.ExcludeByAttribute("*.ExcludeFromCodeCoverage*")
175166
;
176167

177168
foreach(var project in paths.Files.TestProjects)
@@ -183,7 +174,6 @@ Task("Test-OpenCover")
183174
var projectFile = MakeAbsolute(project).ToString();
184175
var dotNetTestSettings = new DotNetCoreTestSettings
185176
{
186-
/* Configuration = "Debug",*/
187177
Configuration = configuration,
188178
NoBuild = true,
189179
NoRestore = true,
@@ -294,6 +284,7 @@ Task("Copy-Files")
294284
//CopyFileToDirectory("./LICENSE", outputDirectory21);
295285

296286
});
287+
297288
// Run dotnet pack to produce NuGet packages from our projects. Versions the package
298289
// using the build number argument on the script which is used as the revision number
299290
// (Last number in 1.0.0.0). The packages are dropped in the Artifacts directory.
@@ -304,33 +295,9 @@ Task("Package-NuGet")
304295
.IsDependentOn("Copy-Files")
305296
.DoesForEach(paths.Files.AllNuspecsProjects,projectNuSpecToPack =>
306297
{
307-
/*
308-
var nuspecFile = projectNuSpecToPack.FullPath;
309-
var nuspecContent = System.IO.File.ReadAllText(nuspecFile);
310-
var nuspecDocument = XDocument.Parse(nuspecContent);
311-
var ns = XNamespace.Get("http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd");
312-
var versionElement = nuspecDocument.Element(ns + "package").Element(ns + "metadata").Element(ns + "version");
313-
var finalVersion= versionElement.Value.Replace("-*", finalVersionSuffix);
314-
versionElement.Value = finalVersion;
315-
System.IO.File.WriteAllText(nuspecFile, nuspecDocument.ToString());
316-
*/
317-
318298
// .NET Core
319299
var nuspecFile=projectNuSpecToPack.FullPath;
320300
var fullBasePath = GetOutputArtifactFromProjectFile(paths.Directories.ArtifactsBinNetCoreapp21,nuspecFile);
321-
322-
/*DotNetCorePack(projectNuSpecToPack.ChangeExtension(".csproj").FullPath,new DotNetCorePackSettings()
323-
{
324-
NoBuild = true,
325-
NoRestore = true,
326-
Configuration = configuration,
327-
OutputDirectory = paths.Directories.ArtifactNugetsDirectory,
328-
VersionSuffix = finalVersionSuffix,//finalVersion,
329-
MSBuildSettings= msBuildSettings,
330-
ArgumentCustomization = args => args
331-
.AppendSwitch("/p:NuspecFile","=",$"{nuspecFile}")
332-
});*/
333-
334301
// normal
335302
NuGetPack(nuspecFile, new NuGetPackSettings {
336303
Version = finalVersion,
@@ -339,9 +306,6 @@ Task("Package-NuGet")
339306
Symbols = false,
340307
NoPackageAnalysis = true
341308
});
342-
343-
344-
//System.IO.File.WriteAllText(nuspecFile, nuspecContent);
345309
});
346310

347311
//////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)