Skip to content

Commit 7756061

Browse files
authored
Merge pull request #23 from harrison314/dev
Dev
2 parents 9ff573f + 56230c4 commit 7756061

File tree

32 files changed

+268
-187
lines changed

32 files changed

+268
-187
lines changed

BuildScripts/Build.ps1

Lines changed: 64 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ Specifies the amount of information to be displayed.
2525
Shows description about tasks.
2626
.PARAMETER DryRun
2727
Performs a dry run.
28-
.PARAMETER Experimental
29-
Uses the nightly builds of the Roslyn script engine.
30-
.PARAMETER Mono
31-
Uses the Mono Compiler rather than the Roslyn script engine.
3228
.PARAMETER SkipToolPackageRestore
3329
Skips restoring of packages.
3430
.PARAMETER ScriptArgs
@@ -41,21 +37,41 @@ https://cakebuild.net
4137

4238
[CmdletBinding()]
4339
Param(
44-
[string]$Script = "build.cake",
40+
[string]$Script,
4541
[string]$Target,
4642
[string]$Configuration,
4743
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
4844
[string]$Verbosity,
4945
[switch]$ShowDescription,
5046
[Alias("WhatIf", "Noop")]
5147
[switch]$DryRun,
52-
[switch]$Experimental,
53-
[switch]$Mono,
5448
[switch]$SkipToolPackageRestore,
5549
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
5650
[string[]]$ScriptArgs
5751
)
5852

53+
# This is an automatic variable in PowerShell Core, but not in Windows PowerShell 5.x
54+
if (-not (Test-Path variable:global:IsCoreCLR)) {
55+
$IsCoreCLR = $false
56+
}
57+
58+
# Attempt to set highest encryption available for SecurityProtocol.
59+
# PowerShell will not set this by default (until maybe .NET 4.6.x). This
60+
# will typically produce a message for PowerShell v2 (just an info
61+
# message though)
62+
try {
63+
# Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48)
64+
# Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
65+
# exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
66+
# installed (.NET 4.5 is an in-place upgrade).
67+
# PowerShell Core already has support for TLS 1.2 so we can skip this if running in that.
68+
if (-not $IsCoreCLR) {
69+
[System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
70+
}
71+
} catch {
72+
Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3'
73+
}
74+
5975
[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
6076
function MD5HashFile([string] $filePath)
6177
{
@@ -85,7 +101,7 @@ function GetProxyEnabledWebClient
85101
{
86102
$wc = New-Object System.Net.WebClient
87103
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
88-
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
104+
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
89105
$wc.Proxy = $proxy
90106
return $wc
91107
}
@@ -96,6 +112,9 @@ if(!$PSScriptRoot){
96112
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
97113
}
98114

115+
if(!$Script){
116+
$Script = Join-Path $PSScriptRoot "build.cake"
117+
}
99118
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
100119
$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins"
101120
$MODULES_DIR = Join-Path $TOOLS_DIR "Modules"
@@ -107,10 +126,14 @@ $PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
107126
$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config"
108127
$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"
109128

129+
$env:CAKE_PATHS_TOOLS = $TOOLS_DIR
130+
$env:CAKE_PATHS_ADDINS = $ADDINS_DIR
131+
$env:CAKE_PATHS_MODULES = $MODULES_DIR
132+
110133
# Make sure tools folder exists
111134
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
112135
Write-Verbose -Message "Creating tools directory..."
113-
New-Item -Path $TOOLS_DIR -Type directory | out-null
136+
New-Item -Path $TOOLS_DIR -Type Directory | Out-Null
114137
}
115138

116139
# Make sure that packages.config exist.
@@ -146,25 +169,37 @@ if (!(Test-Path $NUGET_EXE)) {
146169
}
147170
}
148171

172+
# These are automatic variables in PowerShell Core, but not in Windows PowerShell 5.x
173+
if (-not (Test-Path variable:global:ismacos)) {
174+
$IsLinux = $false
175+
$IsMacOS = $false
176+
}
177+
149178
# Save nuget.exe path to environment to be available to child processed
150-
$ENV:NUGET_EXE = $NUGET_EXE
179+
$env:NUGET_EXE = $NUGET_EXE
180+
$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
181+
"mono `"$NUGET_EXE`""
182+
} else {
183+
"`"$NUGET_EXE`""
184+
}
151185

152186
# Restore tools from NuGet?
153187
if(-Not $SkipToolPackageRestore.IsPresent) {
154188
Push-Location
155189
Set-Location $TOOLS_DIR
156190

157191
# Check for changes in packages.config and remove installed tools if true.
158-
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
192+
[string] $md5Hash = MD5HashFile $PACKAGES_CONFIG
159193
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
160-
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
194+
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
161195
Write-Verbose -Message "Missing or changed package.config hash..."
162196
Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery |
163-
Remove-Item -Recurse
197+
Remove-Item -Recurse -Force
164198
}
165199

166200
Write-Verbose -Message "Restoring tools from NuGet..."
167-
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
201+
202+
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
168203

169204
if ($LASTEXITCODE -ne 0) {
170205
Throw "An error occurred while restoring NuGet tools."
@@ -173,7 +208,7 @@ if(-Not $SkipToolPackageRestore.IsPresent) {
173208
{
174209
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
175210
}
176-
Write-Verbose -Message ($NuGetOutput | out-string)
211+
Write-Verbose -Message ($NuGetOutput | Out-String)
177212

178213
Pop-Location
179214
}
@@ -184,13 +219,13 @@ if (Test-Path $ADDINS_PACKAGES_CONFIG) {
184219
Set-Location $ADDINS_DIR
185220

186221
Write-Verbose -Message "Restoring addins from NuGet..."
187-
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
222+
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
188223

189224
if ($LASTEXITCODE -ne 0) {
190225
Throw "An error occurred while restoring NuGet addins."
191226
}
192227

193-
Write-Verbose -Message ($NuGetOutput | out-string)
228+
Write-Verbose -Message ($NuGetOutput | Out-String)
194229

195230
Pop-Location
196231
}
@@ -201,13 +236,13 @@ if (Test-Path $MODULES_PACKAGES_CONFIG) {
201236
Set-Location $MODULES_DIR
202237

203238
Write-Verbose -Message "Restoring modules from NuGet..."
204-
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
239+
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
205240

206241
if ($LASTEXITCODE -ne 0) {
207242
Throw "An error occurred while restoring NuGet modules."
208243
}
209244

210-
Write-Verbose -Message ($NuGetOutput | out-string)
245+
Write-Verbose -Message ($NuGetOutput | Out-String)
211246

212247
Pop-Location
213248
}
@@ -217,20 +252,23 @@ if (!(Test-Path $CAKE_EXE)) {
217252
Throw "Could not find Cake.exe at $CAKE_EXE"
218253
}
219254

255+
$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
256+
"mono `"$CAKE_EXE`""
257+
} else {
258+
"`"$CAKE_EXE`""
259+
}
220260

221-
222-
# Build Cake arguments
223-
$cakeArguments = @("$Script");
224-
if ($Target) { $cakeArguments += "-target=$Target" }
261+
# Build an array (not a string) of Cake arguments to be joined later
262+
$cakeArguments = @()
263+
if ($Script) { $cakeArguments += "`"$Script`"" }
264+
if ($Target) { $cakeArguments += "-target=`"$Target`"" }
225265
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
226266
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
227267
if ($ShowDescription) { $cakeArguments += "-showdescription" }
228268
if ($DryRun) { $cakeArguments += "-dryrun" }
229-
if ($Experimental) { $cakeArguments += "-experimental" }
230-
if ($Mono) { $cakeArguments += "-mono" }
231269
$cakeArguments += $ScriptArgs
232270

233271
# Start Cake
234272
Write-Host "Running build script..."
235-
&$CAKE_EXE $cakeArguments
273+
Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")"
236274
exit $LASTEXITCODE

BuildScripts/build.cake

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#addin nuget:?package=Cake.Git&version=0.21.0
12

23
var target = Argument("target", "Default");
34
var configuration = Argument("Configuration", "Release");
@@ -8,6 +9,19 @@ var configuration = Argument("Configuration", "Release");
89
string artefacts = "./Artifacts";
910

1011
// ****************************************************************************
12+
13+
void UpdateSettings(DotNetCoreSettings settings)
14+
{
15+
if (settings.EnvironmentVariables == null)
16+
{
17+
settings.EnvironmentVariables = new Dictionary<string, string>();
18+
}
19+
20+
var branch = GitBranchCurrent("..");
21+
//settings.EnvironmentVariables.Add("RepositoryBranch", branch.FriendlyName);
22+
settings.EnvironmentVariables.Add("RepositoryCommit", branch.Tip.Sha);
23+
}
24+
1125
var netCoreBuildSettings = new DotNetCoreBuildSettings()
1226
{
1327
Configuration = configuration,
@@ -16,7 +30,7 @@ var netCoreBuildSettings = new DotNetCoreBuildSettings()
1630
NoRestore = false
1731
};
1832

19-
var netCoreDotNetCorePackSettings = new DotNetCorePackSettings ()
33+
var netCoreDotNetCorePackSettings = new DotNetCorePackSettings()
2034
{
2135
Configuration = configuration,
2236
OutputDirectory = artefacts,
@@ -150,6 +164,7 @@ Task("Pack")
150164
.IsDependentOn("Test")
151165
.Does(()=>
152166
{
167+
UpdateSettings(netCoreDotNetCorePackSettings);
153168
foreach(var projFile in GetFiles("../src/Src/*/*.csproj"))
154169
{
155170
DotNetCorePack(projFile.ToString(), netCoreDotNetCorePackSettings);

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ Fertures:
1616
* Proxy instance generator, for control instancing real implementation (e.g. lazy loading).
1717

1818
The following platforms are supported:
19-
* .Net 4.0, 4.5, 4.6, 4.6.1, NetStandard 1.6, NetStandard 2.0 and UWP applications (NetStandard 1.4)
19+
* .Net Framework 4.0, 4.5, 4.6, 4.6.1, NetStandard 1.6, NetStandard 2.0 and UWP applications (NetStandard 1.4), .Net 5.0
2020

2121
## Getting started
2222

2323
In package manager console:
2424

2525
`PM> Install-Package MassiveDynamicProxyGenerator`
2626

27+
Or
28+
`dotnet add package MassiveDynamicProxyGenerator`
29+
2730
## A Quick Example
2831

2932
Examples of use MassiveDynamicProxyGenerator.
@@ -141,6 +144,10 @@ In package manager console:
141144

142145
`PM> Install-Package MassiveDynamicProxyGenerator.SimpleInjector`
143146

147+
Or
148+
149+
`dotnet add package MassiveDynamicProxyGenerator.SimpleInjector`
150+
144151
Or download [MassiveDynamicProxyGenerator.SimpleInjector](https://www.nuget.org/packages/MassiveDynamicProxyGenerator.SimpleInjector/).
145152

146153
### Register mock
@@ -267,6 +274,10 @@ In package manager console:
267274

268275
`PM> Install-Package MassiveDynamicProxyGenerator.Microsoft.DependencyInjection`
269276

277+
Or
278+
279+
`dotnet add package MassiveDynamicProxyGenerator.Microsoft.DependencyInjection`
280+
270281
Or download [MassiveDynamicProxyGenerator.Microsoft.DependencyInjection](https://www.nuget.org/packages/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/).
271282

272283
### Add decorators

src/Samples/PerformaceExamples/PerformaceExamples.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
65
</PropertyGroup>
76

87
<ItemGroup>
9-
<PackageReference Include="BenchmarkDotNet" Version="0.12.0" />
8+
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
109
</ItemGroup>
1110

1211
<ItemGroup>

src/Samples/SampleWebApplication/SampleWebApplication.csproj

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

7-
<ItemGroup>
8-
<PackageReference Include="Microsoft.AspNetCore.App" />
9-
<PackageReference Include="Microsoft.AspNetCore.Mvc" />
10-
</ItemGroup>
11-
127
<ItemGroup>
138
<ProjectReference Include="..\..\Src\MassiveDynamicProxyGenerator.Microsoft.DependencyInjection\MassiveDynamicProxyGenerator.Microsoft.DependencyInjection.csproj" />
149
<ProjectReference Include="..\..\Src\MassiveDynamicProxyGenerator\MassiveDynamicProxyGenerator.csproj" />

src/Samples/SampleWebApplication/Services/Contract/ICommonServices.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace SampleWebApplication.Services.Contract
88
{
99
public interface ICommonServices
1010
{
11-
IHostingEnvironment HostingEnvironment
11+
IWebHostEnvironment HostingEnvironment
1212
{
1313
get;
1414
}

src/Samples/SampleWebApplication/Startup.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using SampleWebApplication.Services.Contract;
1212
using SampleWebApplication.Services.Implementation;
1313
using SampleWebApplication.Services.Interceptors;
14+
using Microsoft.Extensions.Hosting;
1415

1516
namespace SampleWebApplication
1617
{
@@ -36,12 +37,12 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
3637
services.AddProxy<INotificationService>();
3738
services.AddProxy<ICommonServices, ServiceProviderInterceptor>();
3839

39-
services.AddMvc();
40+
services.AddControllers();
4041

4142
return services.BuildIntercepedServiceProvider();
4243
}
4344

44-
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
45+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
4546
{
4647
if (env.IsDevelopment())
4748
{
@@ -54,11 +55,15 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
5455

5556
app.UseStaticFiles();
5657

57-
app.UseMvc(routes =>
58+
app.UseHttpsRedirection();
59+
60+
app.UseRouting();
61+
62+
app.UseAuthorization();
63+
64+
app.UseEndpoints(endpoints =>
5865
{
59-
routes.MapRoute(
60-
name: "default",
61-
template: "{controller=Home}/{action=Index}/{id?}");
66+
endpoints.MapControllers();
6267
});
6368
}
6469
}

src/Samples/WcfForHipsters.Client/WcfForHipsters.Client.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
5-
<AssemblyName>WcfForHipsters.Client</AssemblyName>
6-
<OutputType>Exe</OutputType>
7-
<PackageId>WcfForHipsters.Client</PackageId>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
85
</PropertyGroup>
96

107
<ItemGroup>
@@ -16,7 +13,7 @@
1613
</ItemGroup>
1714

1815
<ItemGroup>
19-
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
16+
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
2017
</ItemGroup>
2118

2219
<ItemGroup>

0 commit comments

Comments
 (0)