removing app.config and web.config and putting in code
starting support for mysql (for linux)
This commit is contained in:
parent
b6f490be9c
commit
466b273736
1022
.vs/config/applicationhost.config
Normal file
1022
.vs/config/applicationhost.config
Normal file
File diff suppressed because it is too large
Load Diff
@ -72,6 +72,6 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\"</PostBuildEvent>
|
||||
<PostBuildEvent Condition=" '$(OS)' != 'Unix' ">copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -156,7 +156,7 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\"</PostBuildEvent>
|
||||
<PostBuildEvent Condition=" '$(OS)' != 'Unix' ">copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
@ -135,7 +135,7 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\$(TargetName).dll"
|
||||
<PostBuildEvent Condition=" '$(OS)' != 'Unix' ">copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\$(TargetName).dll"
|
||||
copy /Y "$(ProjectDir)GeoIP.dat" "$(SolutionDir)BUILD\plugins\GeoIP.dat"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -1,36 +0,0 @@
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding>
|
||||
<!-- <probing privatePath="lib"/>-->
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
|
||||
<parameters>
|
||||
<parameter value="System.Data.SqlServerCe.4.0" />
|
||||
</parameters>
|
||||
</defaultConnectionFactory>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
|
||||
</providers>
|
||||
</entityFramework>
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<remove invariant="System.Data.SqlServerCe.4.0" />
|
||||
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
|
||||
</DbProviderFactories>
|
||||
</system.data>
|
||||
<connectionStrings>
|
||||
<add name="DefaultConnection"
|
||||
providerName="System.Data.SqlServerCe.4.0"
|
||||
connectionString="Data Source=|DataDirectory|\Database.sdf"/>
|
||||
</connectionStrings>
|
||||
</configuration>
|
30
SharedLibrary/Database/ContextConfiguration.cs
Normal file
30
SharedLibrary/Database/ContextConfiguration.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Data.Entity.SqlServerCompact;
|
||||
using System.Data.SqlServerCe;
|
||||
|
||||
namespace SharedLibrary.Database
|
||||
{
|
||||
class ContextConfiguration : DbConfiguration
|
||||
{
|
||||
public ContextConfiguration()
|
||||
{
|
||||
if (!Utilities.IsRunningOnMono())
|
||||
{
|
||||
SetExecutionStrategy("System.Data.SqlServerCe.4.0", () => new DefaultExecutionStrategy());
|
||||
SetProviderFactory("System.Data.SqlServerCe.4.0", new SqlCeProviderFactory());
|
||||
SetProviderServices("System.Data.SqlServerCe.4.0", SqlCeProviderServices.Instance);
|
||||
SetDefaultConnectionFactory(new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0"));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* SetExecutionStrategy("MySql.Data.MySqlClient", () => new DefaultExecutionStrategy());
|
||||
SetProviderFactory("MySql.Data.MySqlClient", new MySql.Data.MySqlClient.MySqlClientFactory());
|
||||
SetProviderServices("MySql.Data.MySqlClient", new MySql.Data.MySqlClient.MySqlProviderServices());
|
||||
SetDefaultConnectionFactory(new MySql.Data.Entity.MySqlConnectionFactory());*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,10 +11,12 @@ using System.Reflection;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Data.Entity.SqlServerCompact;
|
||||
using System.IO;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace SharedLibrary.Database
|
||||
{
|
||||
|
||||
[DbConfigurationType(typeof(ContextConfiguration))]
|
||||
public class DatabaseContext : DbContext
|
||||
{
|
||||
public DbSet<EFClient> Clients { get; set; }
|
||||
@ -22,7 +24,9 @@ namespace SharedLibrary.Database
|
||||
public DbSet<EFAliasLink> AliasLinks { get; set; }
|
||||
public DbSet<EFPenalty> Penalties { get; set; }
|
||||
|
||||
public DatabaseContext() : base("DefaultConnection")
|
||||
public static string ConnectionString;
|
||||
|
||||
public DatabaseContext() : base(ConnectionString)
|
||||
{
|
||||
System.Data.Entity.Database.SetInitializer(new MigrateDatabaseToLatestVersion<DatabaseContext, Migrations.Configuration>());
|
||||
//Database.CreateIfNotExists();
|
||||
|
@ -148,6 +148,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Configuration\MapConfiguration.cs" />
|
||||
<Compile Include="Configuration\ServerConfiguration.cs" />
|
||||
<Compile Include="Database\ContextConfiguration.cs" />
|
||||
<Compile Include="Database\Importer.cs" />
|
||||
<Compile Include="Database\DatabaseContext.cs" />
|
||||
<Compile Include="Database\Models\EFAlias.cs" />
|
||||
@ -209,7 +210,6 @@
|
||||
<Compile Include="Utilities.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="app.config" />
|
||||
<Compile Include="Dtos\EventInfo.cs" />
|
||||
<Content Include="LibSQLCe\x86\Microsoft.VC90.CRT\msvcr90.dll" />
|
||||
<Content Include="LibSQLCe\x86\Microsoft.VC90.CRT\README_ENU.txt" />
|
||||
@ -240,6 +240,12 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json">
|
||||
<Version>1.1.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MySql.Data">
|
||||
<Version>6.10.6</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MySql.Data.Entity">
|
||||
<Version>6.10.6</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>11.0.1</Version>
|
||||
</PackageReference>
|
||||
@ -261,12 +267,12 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>if not exist "$(ProjectDir)LibSQLCE\x86" md "$(TargetDir)x86"
|
||||
<PostBuildEvent Condition=" '$(OS)' != 'Unix' ">if not exist "$(ProjectDir)LibSQLCE\x86" md "$(TargetDir)x86"
|
||||
xcopy /y "$(ProjectDir)LibSQLCE\x86" "$(TargetDir)x86\"
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>if not exist "$(SolutionDir)BUILD" mkdir "$(SolutionDir)BUILD"
|
||||
<PreBuildEvent Condition=" '$(OS)' != 'Unix' ">if not exist "$(SolutionDir)BUILD" mkdir "$(SolutionDir)BUILD"
|
||||
if not exist "$(SolutionDir)BUILD\userraw\scripts" mkdir "$(SolutionDir)BUILD\userraw\scripts"</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -434,5 +434,7 @@ namespace SharedLibrary
|
||||
#endif
|
||||
return Utilities.PlayersFromStatus(response);
|
||||
}
|
||||
|
||||
public static bool IsRunningOnMono() => Type.GetType("Mono.Runtime") != null;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,19 @@ namespace WebfrontCore
|
||||
.SetBasePath(env.ContentRootPath)
|
||||
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
|
||||
.AddEnvironmentVariables();
|
||||
|
||||
|
||||
Configuration = builder.Build();
|
||||
// fixme: this is really really terrible
|
||||
if (!SharedLibrary.Utilities.IsRunningOnMono())
|
||||
{
|
||||
SharedLibrary.Database.DatabaseContext.ConnectionString = Configuration["ConnectionStrings:WindowsConnection"];
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
SharedLibrary.Database.DatabaseContext.ConnectionString = Configuration["ConnectionStrings:LinuxConnection"];
|
||||
}
|
||||
|
||||
if (!IW4MAdmin.Program.Start())
|
||||
Environment.Exit(-1);
|
||||
|
@ -1,4 +1,4 @@
|
||||
<h3 class="pb-2 text-center ">@ViewBag.Title</h3>
|
||||
<h4 class="pb-2 text-center ">@ViewBag.Title</h4>
|
||||
<div class="row">
|
||||
<table class="table table-striped">
|
||||
<thead class="d-none d-md-table-header-group">
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net452</TargetFramework>
|
||||
@ -33,7 +33,6 @@
|
||||
<Content Remove="bower.json" />
|
||||
<Content Remove="bundleconfig.json" />
|
||||
<Content Remove="compilerconfig.json" />
|
||||
<Content Remove="web.config" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -77,7 +76,6 @@
|
||||
<None Include="bower.json" />
|
||||
<None Include="bundleconfig.json" />
|
||||
<None Include="compilerconfig.json" />
|
||||
<None Include="web.config" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -96,7 +94,11 @@
|
||||
<Folder Include="Views\Account\" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||
<Exec Command="if not "$(SolutionDir)"=="*Undefined*" (
 xcopy /Y "$(SolutionDir)BUILD\Plugins" "$(TargetDir)Plugins\"
)" />
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent Condition=" '$(OS)' != 'Unix' ">if not exist "$(ProjectDir)LibSQLCE\x86" md "$(TargetDir)x86" xcopy /y "$(ProjectDir)LibSQLCE\x86" "$(TargetDir)x86\"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent Condition=" '$(OS)' != 'Unix' ">if not exist "$(SolutionDir)BUILD" mkdir "$(SolutionDir)BUILD" if not exist "$(SolutionDir)BUILD\userraw\scripts" mkdir "$(SolutionDir)BUILD\userraw\scripts"</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,37 +0,0 @@
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
|
||||
</startup>
|
||||
<runtime>
|
||||
<loadFromRemoteSources enabled="true"/>
|
||||
<assemblyBinding>
|
||||
<!-- <probing privatePath="lib"/>-->
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
|
||||
<parameters>
|
||||
<parameter value="System.Data.SqlServerCe.4.0" />
|
||||
</parameters>
|
||||
</defaultConnectionFactory>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
|
||||
</providers>
|
||||
</entityFramework>
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<remove invariant="System.Data.SqlServerCe.4.0" />
|
||||
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
|
||||
</DbProviderFactories>
|
||||
</system.data>
|
||||
<connectionStrings>
|
||||
<add name="DefaultConnection"
|
||||
providerName="System.Data.SqlServerCe.4.0"
|
||||
connectionString="Data Source=|DataDirectory|\Database.sdf"/>
|
||||
</connectionStrings>
|
||||
</configuration>
|
@ -9,5 +9,9 @@
|
||||
},
|
||||
"Web": {
|
||||
"Address": "http://127.0.0.1:5000"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"WindowsConnection": "Data Source=|DataDirectory|\\Database.sdf",
|
||||
"LinuxConnection": "server=server;user=user;database=db;password=pass"
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
|
||||
<!--
|
||||
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
|
||||
-->
|
||||
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
|
||||
</handlers>
|
||||
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
|
||||
</system.webServer>
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user