升级工程:升级到2.2框架

This commit is contained in:
Argo-Surface 2018-12-05 17:29:09 +08:00
parent d23e3aab92
commit f53d76ad49
14 changed files with 14 additions and 199 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\Keys\Longbow.Utility.snk</AssemblyOriginatorKeyFile>
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
@ -14,11 +14,11 @@
<ItemGroup>
<PackageReference Include="Bootstrap.Security.Mvc" Version="1.1.0" />
<PackageReference Include="Longbow.Logging" Version="1.1.0" />
<PackageReference Include="Longbow.Logging" Version="1.1.1" />
<PackageReference Include="Longbow.Web" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.3.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.6" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
</ItemGroup>

View File

@ -74,7 +74,7 @@ namespace Bootstrap.Admin
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
JsonConvert.DefaultSettings = () => options.SerializerSettings;
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => options.Cookie.Path = "/");
services.AddApiVersioning(option =>
{

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\Keys\Longbow.Utility.snk</AssemblyOriginatorKeyFile>
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="Bootstrap.Security.Mvc" Version="1.1.0" />
<PackageReference Include="Longbow.Cache" Version="1.1.0" />
<PackageReference Include="Longbow.Logging" Version="1.1.0" />
<PackageReference Include="Longbow.Logging" Version="1.1.1" />
<PackageReference Include="Longbow.Web" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

View File

@ -56,7 +56,7 @@ namespace Bootstrap.Client
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
JsonConvert.DefaultSettings = () => options.SerializerSettings;
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options =>
{
options.Cookie.Path = "/";

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\Keys\Longbow.Utility.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

View File

@ -126,11 +126,11 @@ namespace Bootstrap.DataAccess.MongoDB
var connectString = DbAdapterManager.GetConnectionString("ba");
if (string.IsNullOrEmpty(connectString)) throw new InvalidOperationException("Please set the BA default value in configuration file.");
var seq = connectString.Split(";", StringSplitOptions.RemoveEmptyEntries);
if (seq.Length != 2) throw new InvalidOperationException("ConnectionString invalid in configuration file. It should be mongodb://127.0.0.1:27017;Data Source=BootstrapAdmin");
var seq = connectString.SpanSplit(";", StringSplitOptions.RemoveEmptyEntries);
if (seq.Count != 2) throw new InvalidOperationException("ConnectionString invalid in configuration file. It should be mongodb://127.0.0.1:27017;Data Source=BootstrapAdmin");
var client = new MongoClient(seq[0]);
_db = client.GetDatabase(seq[1].Split("=", StringSplitOptions.RemoveEmptyEntries).LastOrDefault());
_db = client.GetDatabase(seq[1].SpanSplit("=", StringSplitOptions.RemoveEmptyEntries).LastOrDefault());
}
private static void InitClassMap()

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\Keys\Longbow.Utility.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

View File

@ -15,7 +15,7 @@
<PackageReference Include="Longbow.Configuration" Version="1.1.0" />
<PackageReference Include="Longbow.Data" Version="1.1.0" />
<PackageReference Include="Longbow.Security.Cryptography" Version="1.1.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.1.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.0" />
</ItemGroup>
<ItemGroup>

View File

@ -15,7 +15,7 @@
<PackageReference Include="Longbow.Security.Cryptography" Version="1.1.0" />
<PackageReference Include="Longbow.Web" Version="1.1.0" />
<PackageReference Include="Longbow.Cache" Version="1.1.0" />
<PackageReference Include="Longbow" Version="1.1.0" />
<PackageReference Include="Longbow" Version="1.1.1" />
</ItemGroup>
</Project>

View File

@ -59,8 +59,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MySQL", "MySQL", "{084E2E94
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bootstrap.DataAccess.MySQL", "Bootstrap.DataAccess.MySQL\Bootstrap.DataAccess.MySQL.csproj", "{B6877AEA-EC65-47DA-BA6E-FD657729C285}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTest", "UnitTest\UnitTest.csproj", "{F301A509-31AE-45EA-9453-CA8C0A73DE99}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -95,10 +93,6 @@ Global
{B6877AEA-EC65-47DA-BA6E-FD657729C285}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6877AEA-EC65-47DA-BA6E-FD657729C285}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6877AEA-EC65-47DA-BA6E-FD657729C285}.Release|Any CPU.Build.0 = Release|Any CPU
{F301A509-31AE-45EA-9453-CA8C0A73DE99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F301A509-31AE-45EA-9453-CA8C0A73DE99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F301A509-31AE-45EA-9453-CA8C0A73DE99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F301A509-31AE-45EA-9453-CA8C0A73DE99}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,98 +0,0 @@
using Bootstrap.DataAccess;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace UnitTest
{
public class ExceptionsTest
{
[Fact]
public void RetrieveExceptions_Array()
{
var config = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddInMemoryCollection(new List<KeyValuePair<string, string>>() {
new KeyValuePair<string, string>("DB:0:Enabled", "true"),
new KeyValuePair<string, string>("DB:0:Widget", "Bootstrap.DataAccess"),
new KeyValuePair<string, string>("DB:0:ConnectionStrings:ba", "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa")
})
.Build();
new ServiceCollection()
.AddSingleton<IConfiguration>(config)
.AddConfigurationManager(config)
.AddDbAdapter(config);
Exceptions excep = new Exceptions();
var result = excep.RetrieveExceptions();
var num = result.Count();
Assert.True(num >= 0);
}
[Fact]
public void RetrieveExceptions_SQLite_Array()
{
var config = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddInMemoryCollection(new List<KeyValuePair<string, string>>() {
new KeyValuePair<string, string>("DB:0:Enabled", "true"),
new KeyValuePair<string, string>("DB:0:Widget", "Bootstrap.DataAccess.SQLite"),
new KeyValuePair<string, string>("DB:0:DBProviderFactory", "Microsoft.Data.Sqlite.SqliteFactory, Microsoft.Data.Sqlite"),
new KeyValuePair<string, string>("DB:0:ConnectionStrings:ba", "Data Source=BootstrapAdmin.db;")
})
.Build();
new ServiceCollection()
.AddSingleton<IConfiguration>(config)
.AddConfigurationManager(config)
.AddDbAdapter(config);
Exceptions excep = new Exceptions();
var result = excep.RetrieveExceptions();
var num = result.Count();
Assert.True(num >= 0);
}
[Fact]
public void RetrieveExceptions_MySQL_Array()
{
var config = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddInMemoryCollection(new List<KeyValuePair<string, string>>() {
new KeyValuePair<string, string>("DB:0:Enabled", "true"),
new KeyValuePair<string, string>("DB:0:Widget", "Bootstrap.DataAccess.MySQL"),
new KeyValuePair<string, string>("DB:0:DBProviderFactory", "MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data"),
new KeyValuePair<string, string>("DB:0:ConnectionStrings:ba", "Server=10.211.55.2;Database=BA;Uid=argozhang;Pwd=argo@163.com;SslMode=none;")
})
.Build();
new ServiceCollection()
.AddSingleton<IConfiguration>(config)
.AddConfigurationManager(config)
.AddDbAdapter(config);
Exceptions excep = new Exceptions();
var result = excep.RetrieveExceptions();
var num = result.Count();
Assert.True(num >= 0);
}
[Fact]
public async void ClearExceptions_Void()
{
StaticMethods.Setup();
Exceptions excep = new Exceptions();
var method = excep.GetType().GetMethod("ClearExceptions", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
method.Invoke(excep, null);
await System.Threading.Tasks.Task.Delay(1000);
}
}
}

View File

@ -1,23 +0,0 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
namespace UnitTest
{
internal static class StaticMethods
{
public static void Setup()
{
var config = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile("appsettings.Development.json", true, true)
.Build();
new ServiceCollection()
.AddSingleton<IConfiguration>(config)
.AddConfigurationManager(config)
.AddDbAdapter(config);
}
}
}

View File

@ -1,40 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Bootstrap.Admin\Startup.cs" Link="Startup.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="..\Bootstrap.Admin\appsettings.Development.json" Link="appsettings.Development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="..\Bootstrap.Admin\appsettings.json" Link="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.5" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.1.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bootstrap.Admin\Bootstrap.Admin.csproj" />
<ProjectReference Include="..\Bootstrap.DataAccess.MySQL\Bootstrap.DataAccess.MySQL.csproj" />
<ProjectReference Include="..\Bootstrap.DataAccess.SQLite\Bootstrap.DataAccess.SQLite.csproj" />
<ProjectReference Include="..\Bootstrap.DataAccess\Bootstrap.DataAccess.csproj" />
</ItemGroup>
</Project>

View File

@ -1,18 +0,0 @@
using Bootstrap.Admin;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Xunit;
namespace UnitTest
{
public class UnitTest1
{
[Fact]
public void Test1()
{
var server = new TestServer(WebHost.CreateDefaultBuilder()
.UseStartup<Startup>());
}
}
}