diff --git a/.gitignore b/.gitignore index 42b2dfbe788f077f48963f4649f4acf2f4393143..d2df1da5b5077d597142e85e19812ba900a4e81c 100644 --- a/.gitignore +++ b/.gitignore @@ -265,5 +265,6 @@ __pycache__/ *.pyc #cake -tools/ -dist/ \ No newline at end of file +tools/* +!tools/packages.config +dist/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a60ae9cac3363615b4f1ae284ba69ccae900c97e..58b4648128ed7fb6a416446cf5200f8e05e6e42a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,3 @@ - - stages: - build - test @@ -8,30 +6,30 @@ stages: - build-release - semantic-release - release - + build: - before_script: - - PowerShell .\build.ps1 -Target Clean - - PowerShell .\build.ps1 -Target Restore-NuGet-Packages stage: build script: - - PowerShell .\build.ps1 -Target Build + - PowerShell .\build.ps1 -Target Build -Configuration Debug + variables: + GIT_STRATEGY: clone except: variables: - $GITLAB_USER_ID == $GIT_BOT_USER_ID - + test: stage: test script: - - PowerShell .\build.ps1 -Target Resharper - - PowerShell .\build.ps1 -Target Run-Unit-Tests + - PowerShell .\build.ps1 -Target LinterAndTest -Configuration Debug variables: GIT_STRATEGY: none dependencies: - build artifacts: reports: - junit: TestResult.xml + junit: "./Artifacts/TestResults.xml" + paths: + - "./Artifacts/*" except: variables: - $GITLAB_USER_ID == $GIT_BOT_USER_ID @@ -39,7 +37,7 @@ test: update-assembly-info: stage: update-assembly-info script: - - PowerShell .\build.ps1 -Target Update-Assembly-Info + - PowerShell .\build.ps1 -Target UpdateAssemblyInfo variables: GIT_STRATEGY: none dependencies: @@ -51,12 +49,10 @@ update-assembly-info: - $GITLAB_USER_ID == $GIT_BOT_USER_ID build-release: - before_script: - - PowerShell .\build.ps1 -Target Clean - - PowerShell .\build.ps1 -Target Restore-NuGet-Packages stage: build-release script: - - PowerShell .\build.ps1 -Target Build-Release + - PowerShell .\build.ps1 -Target Build -Configuration Release + - PowerShell .\build.ps1 -Configuration Release -Target NugetPack variables: GIT_STRATEGY: none dependencies: @@ -80,11 +76,11 @@ docs: except: variables: - $GITLAB_USER_ID == $GIT_BOT_USER_ID - + semantic-release: stage: semantic-release script: - - PowerShell .\build.ps1 -Target Semantic-Release + - PowerShell .\build.ps1 -Target SemanticRelease variables: GIT_STRATEGY: none dependencies: @@ -94,15 +90,18 @@ semantic-release: except: variables: - $GITLAB_USER_ID == $GIT_BOT_USER_ID - + release: + before_script: stage: release script: - - PowerShell .\build.ps1 -Target Build-Release + - PowerShell .\build.ps1 -Target Build -Configuration Release + - PowerShell .\build.ps1 -Configuration Release -Target NugetPack + - PowerShell .\build.ps1 -Configuration Release -Target NugetPush --nugetApiKey="$NUGET_API_KEY" variables: - GIT_STRATEGY: none + GIT_STRATEGY: clone artifacts: paths: - - dist + - "./Artifacts/*" only: - tags diff --git a/.releaserc b/.releaserc index 576a3f725c1310a69365c11aae327a9f61e5dc47..72ff2701baf27f6738b07f990506607bcc8dd562 100644 --- a/.releaserc +++ b/.releaserc @@ -20,4 +20,4 @@ "message": "Chore: ${nextRelease.version}\n\n${nextRelease.notes}" }] ] -} \ No newline at end of file +} diff --git a/build.cake b/build.cake index 9167f136cd91b4c3805451f5c14b6009130cae7c..cfb6a113c06df741f752ffe39de23f5c190ffe09 100644 --- a/build.cake +++ b/build.cake @@ -1,241 +1,307 @@ #tool nuget:?package=NUnit.ConsoleRunner&version=3.9.0 #tool nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2018.3.4 - +#tool nuget:?package=vswhere&version=2.6.7 + #addin nuget:https://api.nuget.org/v3/index.json?package=Cake.Npx&version=1.3.0 #addin nuget:https://api.nuget.org/v3/index.json?package=Cake.Issues&version=0.6.2 #addin nuget:https://api.nuget.org/v3/index.json?package=Cake.Issues.InspectCode&version=0.6.1 #addin nuget:https://api.nuget.org/v3/index.json?package=Cake.FileHelpers&version=3.1.0 - ////////////////////////////////////////////////////////////////////// // ARGUMENTS ////////////////////////////////////////////////////////////////////// - var target = Argument("target", "Default"); var configuration = Argument("configuration", "Release"); +var nugetApiKey = Argument<string>("nugetApiKey", null); ////////////////////////////////////////////////////////////////////// // PREPARATION ////////////////////////////////////////////////////////////////////// - // Define directories. -string projectName; -string projectPath; -DirectoryPath buildDir; -FilePath solutionFile; +var projects = GetFiles("./**/*.csproj"); +var artifactsDir = Directory("./Artifacts"); +string nupkgDir; +var solutionFile = GetFiles("./**/*.sln").First(); +var projectName = solutionFile.GetFilenameWithoutExtension().ToString(); +var assemblyInfoSubPath = "Properties/AssemblyInfo.cs"; +var nugetSource = "https://api.nuget.org/v3/index.json"; + +// get latest MSBuild version +var vsLatest = VSWhereLatest(); +var msBuildPathX64 = (vsLatest == null) ? null : vsLatest.CombineWithFilePath("./MSBuild/Current/Bin/MSBuild.exe"); // Error rules for resharper // Example: {"InconsistentNaming", "RedundantUsingDirective"}; -string [] resharperErrorRules = {}; +string[] resharperErrorRules = {}; +// Paths to exclude from dupFinder +List<string> dupFinderExcludePatterns = projects.Select( x => $"{x.GetDirectory().ToString()}/{assemblyInfoSubPath}").ToList(); +string[] dupFinderExcludeCodeRegionsByNameSubstring = { "DupFinder Exclusion" }; + +Action <NpxSettings> requiredSemanticVersionPackages = settings => + settings.AddPackage("semantic-release") + .AddPackage("@semantic-release/commit-analyzer") + .AddPackage("@semantic-release/release-notes-generator") + .AddPackage("@semantic-release/gitlab") + .AddPackage("@semantic-release/git") + .AddPackage("@semantic-release/exec") + .AddPackage("conventional-changelog-eslint"); + +/////////////////////////////////////////////////////////////////////////////// +// SETUP / TEARDOWN +/////////////////////////////////////////////////////////////////////////////// +Setup(context =>{ + nupkgDir = $"{artifactsDir.ToString()}/nupkg"; + Information("Running tasks..."); +}); -Action<NpxSettings> requiredSemanticVersionPackages = settings => settings - .AddPackage("semantic-release") - .AddPackage("@semantic-release/commit-analyzer") - .AddPackage("@semantic-release/release-notes-generator") - .AddPackage("@semantic-release/gitlab") - .AddPackage("@semantic-release/git") - .AddPackage("@semantic-release/exec") - .AddPackage("conventional-changelog-eslint"); +Teardown(context =>{ + Information("Finished running tasks."); +}); ////////////////////////////////////////////////////////////////////// // TASKS ////////////////////////////////////////////////////////////////////// - -Task("Get-Project-Name") - .Does(() => -{ - var solutions = GetFiles("./**/*.sln"); - projectName = solutions.First().GetFilenameWithoutExtension().ToString(); - Information("Project Name: {0}", projectName); +Task("Clean") +.Description("Cleans all build and artifacts directories") +.Does(() =>{ + var settings = new DeleteDirectorySettings { + Recursive = true, + Force = true + }; - solutionFile = solutions.First().ToString(); - Information("Solution File: {0}", solutionFile.ToString()); + var directoriesToDelete = new List<DirectoryPath>(); - projectPath = Context.Environment.WorkingDirectory.ToString().ToString() + "/src"; - Information("Project Directory: {0}", projectPath); + foreach(var project in projects) { + directoriesToDelete.Add(Directory($"{project.GetDirectory()}/obj")); + directoriesToDelete.Add(Directory($"{project.GetDirectory()}/bin")); + } - buildDir = Directory(projectPath + "/" + projectName + "/bin") + Directory(configuration); - Information("Build Directory: {0}", buildDir.ToString()); + directoriesToDelete.Add(artifactsDir); + + foreach(var dir in directoriesToDelete) { + if (DirectoryExists(dir)) { + Information($"Cleaning path {dir} ..."); + DeleteDirectory(dir, settings); + } + } }); -Task("Clean") - .IsDependentOn("Get-Project-Name") - .Does(() => -{ - CleanDirectory(buildDir); - CleanDirectory("./dist"); +Task("Restore") +.Does(() =>{ + // Restore all NuGet packages. + Information($"Restoring {solutionFile}..."); + NuGetRestore(solutionFile, new NuGetRestoreSettings { + NoCache = true + }); +}); + +Task("DupFinder") +.Description("Find duplicates in the code") +.Does(() =>{ + var settings = new DupFinderSettings() { + ShowStats = true, + ShowText = true, + OutputFile = $"{artifactsDir}/dupfinder.xml", + ExcludeCodeRegionsByNameSubstring = dupFinderExcludeCodeRegionsByNameSubstring, + ExcludePattern = dupFinderExcludePatterns.ToArray(), + ThrowExceptionOnFindingDuplicates = true + }; + DupFinder(solutionFile, settings); +}); + +Task("InspectCode") +.Description("Inspect the code using Resharper's rule set") +.Does(() =>{ + var settings = new InspectCodeSettings() { + SolutionWideAnalysis = true, + OutputFile = $"{artifactsDir}/inspectcode.xml", + ThrowExceptionOnFindingViolations = false + }; + InspectCode(solutionFile, settings); + + var issues = ReadIssues( + InspectCodeIssuesFromFilePath($"{artifactsDir}/inspectcode.xml"), Context.Environment.WorkingDirectory); + + Information("{0} issues are found.", issues.Count()); + + var errorIssues = issues.Where(issue =>resharperErrorRules.Any(issue.Rule.Contains)).ToList(); + + if (errorIssues.Any()) { + var errorMessage = errorIssues.Aggregate(new StringBuilder(), (stringBuilder, issue) =>stringBuilder.AppendFormat("FileName: {0} Line: {1} Message: {2}{3}", issue.AffectedFileRelativePath, issue.Line, issue.Message, Environment.NewLine)); + throw new CakeException($"{errorIssues.Count} errors detected: {Environment.NewLine}{errorMessage}."); + } }); -Task("Restore-NuGet-Packages") - .IsDependentOn("Get-Project-Name") - .Does(() => -{ - NuGetRestore(solutionFile); +Task("Test") +.Does(() =>{ + NUnit3($"./src/**/bin/{configuration}/*.Tests.dll", new NUnit3Settings { + // generate the xml file + NoResults = false, + Results = new NUnit3Result[] { + new NUnit3Result() { + FileName = $"{artifactsDir}/TestResults.xml", + Transform = Context.Environment.WorkingDirectory + "/nunit3-junit.xslt" + } + } + }); }); -Task("Resharper") - .IsDependentOn("Get-Project-Name") - .Does(() => -{ - FilePath dupLog = Context.Environment.WorkingDirectory + "/Resharper/dupfinder.xml"; - FilePath inspectLog = Context.Environment.WorkingDirectory + "/Resharper/inspectcode.xml"; - - DupFinder(solutionFile, new DupFinderSettings() { - OutputFile = dupLog.ToString() - }); - - Information("DupFinder Log:{0}{1}", Environment.NewLine, FileReadText(dupLog)); - - InspectCode(solutionFile, new InspectCodeSettings() { - OutputFile = inspectLog.ToString() - }); - - var issues = ReadIssues( - InspectCodeIssuesFromFilePath(inspectLog.ToString()), - Context.Environment.WorkingDirectory); - - Information("{0} issues are found.", issues.Count()); - - Information("InspectCode Log:{0}{1}", Environment.NewLine, FileReadText(inspectLog)); - - var errorIssues = issues.Where(issue => resharperErrorRules.Any(issue.Rule.Contains)).ToList(); - - if(errorIssues.Any()) - { - var errorMessage = errorIssues.Aggregate(new StringBuilder(), (stringBuilder, issue) => stringBuilder.AppendFormat("FileName: {0} Line: {1} Message: {2}{3}", issue.AffectedFileRelativePath, issue.Line, issue.Message, Environment.NewLine)); - throw new CakeException($"{errorIssues.Count} errors detected: {Environment.NewLine}{errorMessage}."); - } +Task("NugetPush") +.Does(() =>{ + var nupkgs = GetFiles($"{nupkgDir}/*.nupkg"); + + Information("Need to push {0} packages", nupkgs.Count); + foreach(var nupkg in nupkgs) { + Information("Pushing {0}", nupkg); + NuGetPush(nupkg, new NuGetPushSettings { + Source = nugetSource, + ApiKey = nugetApiKey + }); + } }); - -Task("Update-Assembly-Info") - .IsDependentOn("Get-Project-Name") - .Does(() => -{ - - Information("Running semantic-release in dry run mode to extract next semantic version number"); - - string[] semanticReleaseOutput; - Npx("semantic-release", "--dry-run", requiredSemanticVersionPackages, out semanticReleaseOutput); - - Information(string.Join(Environment.NewLine, semanticReleaseOutput)); - - var nextSemanticVersionNumber = ExtractNextSemanticVersionNumber(semanticReleaseOutput); - - if (nextSemanticVersionNumber == null) { - Warning("There are no relevant changes. AssemblyInfo won't be updated!"); - } else { - Information("Next semantic version number is {0}", nextSemanticVersionNumber); - - var assemblyVersion = $"{nextSemanticVersionNumber}.0"; - - CreateAssemblyInfo(projectPath + "/" + projectName + "/Properties/AssemblyInfo.cs", new AssemblyInfoSettings{ - Product = projectName, - Title = projectName, - Company = "RWTH Aachen University IT Center", - Version = assemblyVersion, - FileVersion = assemblyVersion, - InformationalVersion = assemblyVersion, - Copyright = "RWTH Aachen University IT Center " + DateTime.Now.Year - }); - } + +Task("NugetPack") +.Does(() =>{ + foreach(var project in projects) { + var nuspec = $"{project.GetDirectory()}/{project.GetFilenameWithoutExtension()}.nuspec"; + if(!project.ToString().EndsWith(".Tests") + && FileExists(nuspec)) + { + Information("Packing {0}...", nuspec); + + + + if(!DirectoryExists(nupkgDir)) { + CreateDirectory(nupkgDir); + } + + NuGetPack(project.ToString() ,new NuGetPackSettings + { + OutputDirectory = nupkgDir, + Properties = new Dictionary<string, string> { {"Configuration", "Release"}} + }); + } + } }); - -Task("Build-Release") - .IsDependentOn("Get-Project-Name") - .Does(() => -{ - if(IsRunningOnWindows()) - { - // Use MSBuild - MSBuild(solutionFile, settings => - { - settings.SetConfiguration(configuration); - settings.WithProperty("DebugSymbols", "false"); - settings.WithProperty("DebugType", "None"); - }); - } - else - { - // Use XBuild - XBuild(solutionFile, settings => - { - settings.SetConfiguration(configuration); - settings.WithProperty("DebugSymbols", "false"); - settings.WithProperty("DebugType", "None"); - }); - } - CopyDirectory(buildDir, "./dist"); + + +Task("UpdateAssemblyInfo") +.Does(() =>{ + Information("Running semantic-release in dry run mode to extract next semantic version number"); + + string[] semanticReleaseOutput; + Npx("semantic-release", "--dry-run", requiredSemanticVersionPackages, out semanticReleaseOutput); + + Information(string.Join(Environment.NewLine, semanticReleaseOutput)); + + var nextSemanticVersionNumber = ExtractNextSemanticVersionNumber(semanticReleaseOutput); + + if (nextSemanticVersionNumber == null) { + Warning("There are no relevant changes. AssemblyInfo won't be updated!"); + } else { + Information("Next semantic version number is {0}", nextSemanticVersionNumber); + + var assemblyVersion = $"{nextSemanticVersionNumber}.0"; + + foreach(var project in projects) { + CreateAssemblyInfo($"{project.GetDirectory()}/{assemblyInfoSubPath}", new AssemblyInfoSettings { + Product = project.GetFilenameWithoutExtension().ToString(), + Title = project.GetFilenameWithoutExtension().ToString(), + Company = "IT Center, RWTH Aachen University", + Version = assemblyVersion, + FileVersion = assemblyVersion, + InformationalVersion = assemblyVersion, + Copyright = $"{DateTime.Now.Year} IT Center, RWTH Aachen University", + Description = $"{project.GetFilenameWithoutExtension().ToString()} is a part of the CoScInE group." + }); + } + } }); Task("Build") - .IsDependentOn("Get-Project-Name") - .Does(() => -{ - if(IsRunningOnWindows()) - { - // Use MSBuild - MSBuild(solutionFile, settings => - { - settings.SetConfiguration(configuration); - settings.WithProperty("RunCodeAnalysis", "true"); - }); - } - else - { - // Use XBuild - XBuild(solutionFile, settings => - { - settings.SetConfiguration(configuration); - settings.WithProperty("RunCodeAnalysis", "true"); - }); - } -}); +.IsDependentOn("Clean") +.IsDependentOn("Restore") +.Does(() =>{ + if (IsRunningOnWindows()) { + var frameworkSettingsWindows = new MSBuildSettings { + Configuration = configuration, + Restore = true + }; + + frameworkSettingsWindows.ToolPath = msBuildPathX64; + frameworkSettingsWindows.WorkingDirectory = Context.Environment.WorkingDirectory; + + if (configuration.Equals("Release")) { + frameworkSettingsWindows.WithProperty("DebugSymbols", "false"); + frameworkSettingsWindows.WithProperty("DebugType", "None"); + } + // Use MSBuild + Information($"Building {solutionFile}"); + MSBuild(solutionFile, frameworkSettingsWindows); + } + else { + var frameworkSettingsUnix = new XBuildSettings { + Configuration = configuration + }; + + if (configuration.Equals("Release")) { + frameworkSettingsUnix.WithProperty("DebugSymbols", "false"); + frameworkSettingsUnix.WithProperty("DebugType", "None"); + } + // Use XBuild + Information($"Building {solutionFile}"); + XBuild(solutionFile, frameworkSettingsUnix); + } + + if (configuration.Equals("Release")) { + if(!DirectoryExists(artifactsDir)) { + CreateDirectory(artifactsDir); + } + + foreach(var project in projects) { + if(!project.GetDirectory().ToString().EndsWith(".Tests") + && !FileExists($"{project.GetDirectory()}/{project.GetFilenameWithoutExtension()}.nuspec")) + { + Information($"Copying {project.GetDirectory()}/bin/{configuration}/* to {artifactsDir}"); + CopyDirectory($"{project.GetDirectory()}/bin/{configuration}/", artifactsDir); + } + } + } -Task("Run-Unit-Tests") - .Does(() => -{ - NUnit3("./src/**/bin/" + configuration + "/*.Tests.dll", new NUnit3Settings { - // generate the xml file - NoResults = false, - Results = new NUnit3Result[]{new NUnit3Result(){ - FileName = Context.Environment.WorkingDirectory + "/TestResult.xml", - Transform = Context.Environment.WorkingDirectory + "/nunit3-junit.xslt" - }} - }); }); -Task("Semantic-Release") - .Does(() => -{ - Npx("semantic-release", requiredSemanticVersionPackages); +Task("SemanticRelease") +.Does(() =>{ + Npx("semantic-release", requiredSemanticVersionPackages); }); -////////////////////////////////////////////////////////////////////// -// TASK TARGETS -////////////////////////////////////////////////////////////////////// +Task("Linter") +.Description("Run DupFinder and InspectCode") +.IsDependentOn("DupFinder") +.IsDependentOn("InspectCode"); + +Task("LinterAndTest") +.Description("Run Linter and Tests") +.IsDependentOn("Linter") +.IsDependentOn("Test"); Task("Default") - .IsDependentOn("Clean") - .IsDependentOn("Restore-NuGet-Packages") - .IsDependentOn("Resharper") - .IsDependentOn("Build") - .IsDependentOn("Run-Unit-Tests"); +.IsDependentOn("Clean") +.IsDependentOn("Restore") +.IsDependentOn("DupFinder") +.IsDependentOn("InspectCode") +.IsDependentOn("Build") +.IsDependentOn("Test"); ////////////////////////////////////////////////////////////////////// // EXECUTION ////////////////////////////////////////////////////////////////////// - RunTarget(target); /////////////////////////////////////////////////////////////////////////////// // Helpers /////////////////////////////////////////////////////////////////////////////// +string ExtractNextSemanticVersionNumber(string[] semanticReleaseOutput) { + var extractRegEx = new System.Text.RegularExpressions.Regex("^.+next release version is (?<SemanticVersionNumber>.*)$"); -string ExtractNextSemanticVersionNumber(string[] semanticReleaseOutput) -{ - var extractRegEx = new System.Text.RegularExpressions.Regex("^.+next release version is (?<SemanticVersionNumber>.*)$"); - - return semanticReleaseOutput - .Select(line => extractRegEx.Match(line).Groups["SemanticVersionNumber"].Value) - .Where(line => !string.IsNullOrWhiteSpace(line)) - .SingleOrDefault(); -} \ No newline at end of file + return semanticReleaseOutput.Select(line =>extractRegEx.Match(line).Groups["SemanticVersionNumber"].Value).Where(line =>!string.IsNullOrWhiteSpace(line)).SingleOrDefault(); +} diff --git a/src/Database/Coscine.Database.Key.snk b/src/Database/Coscine.Database.Key.snk new file mode 100644 index 0000000000000000000000000000000000000000..69246d13067ee192c09d110bcf9cd2e090ba108f Binary files /dev/null and b/src/Database/Coscine.Database.Key.snk differ diff --git a/src/Database/DataModel/CsDatabase.tt b/src/Database/DataModel/CsDatabase.tt index d6a001f351d25410694cad81a3718730aabc30c4..3bb42567d2c761f26d38e2b26b9139784781e29c 100644 --- a/src/Database/DataModel/CsDatabase.tt +++ b/src/Database/DataModel/CsDatabase.tt @@ -1,65 +1,19 @@ +#region DupFinder Exclusion <#@ template language="C#" debug="True" hostSpecific="False" #> <#@ output extension=".generated.cs" #> -<# //@ include file="$(LinqToDBT4SqlServerTemplatesDirectory)LinqToDB.SqlServer.Tools.ttinclude" #> -<# //@ include file="$(LinqToDBT4SqlServerTemplatesDirectory)PluralizationService.ttinclude" #> <#@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.SqlServer.Tools.ttinclude" #> <#@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> +<#@ include file="$(ProjectDir)DatabaseConnection.t4" #> -<# - /* - 1. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model - and copy content from this file to it. For example: - - MyProject - DataModels - MyDatabase.tt - - 2. Modify the connection settings below to connect to your database. - - 3. Add connection string to the web/app.config file: - - <connectionStrings> - <add name="MyDatabase" providerName="System.Data.SqlClient" - connectionString="Data Source=.;Database=MyDatabase;User Id=User;Password=TestPassword;" /> - </connectionStrings> - - 4. To access your database use the following code: - - using (var db = new MyDatabaseDB()) - { - var q = - from c in db.Customers - select c - - foreach (var c in q) - Console.WriteLine(c.ContactName); - } - - 5. See more at https://github.com/linq2db/t4models - - If you need to use the Microsoft.SqlServer.Types namespace, install the Microsoft.SqlServer.Types nuget, - and replace the following include at the top of this file: - - "$(ProjectDir)LinqToDB.Templates\LinqToDB.SqlServer.Tools.ttinclude" - - with - - "$(ProjectDir)LinqToDB.Templates\LinqToDB.SqlServer.SqlTypes.Tools.ttinclude" - */ - - NamespaceName = "Coscine.Database.Model"; -#> - -<#@ include file="$(ProjectDir)DatabaseConnection.ttinclude" #> +<# NamespaceName = "Coscine.Database.Model"; #> <# DatabaseConnection dbKeys = new DatabaseConnection(); string[] keys = dbKeys.GetConnectionKeys(); - LoadSqlServerMetadata(keys[0], keys[1], keys[2], keys[3]); -// LoadSqlServerMetadata(".", "MyDatabase"); // Integrated Security -// LoadSqlServerMetadata(string connectionString); GenerateModel(); #> -<#@ include file="$(ProjectDir)DataModelConstructor.ttinclude" #> \ No newline at end of file +<#@ include file="../DataModelConstructor.t4"#> + +#endregion \ No newline at end of file diff --git a/src/Database/DataModelConstructor.cs b/src/Database/DataModelConstructor.t4 similarity index 100% rename from src/Database/DataModelConstructor.cs rename to src/Database/DataModelConstructor.t4 diff --git a/src/Database/DataModelConstructor.ttinclude b/src/Database/DataModelConstructor.ttinclude deleted file mode 100644 index 473ca68951a4b1997919aa8b417b1c7307be64b5..0000000000000000000000000000000000000000 --- a/src/Database/DataModelConstructor.ttinclude +++ /dev/null @@ -1,12 +0,0 @@ -namespace Coscine.Database.Model -{ - public partial class MopedDB - { - public MopedDB(string providerName, string connectionString) - : base(providerName, connectionString) - { - InitDataContext(); - InitMappingSchema(); - } - } -} \ No newline at end of file diff --git a/src/Database/Database.csproj b/src/Database/Database.csproj index b99fc2f4ce7cfcc54baebebb3941eee974aa2778..1cc1489ed7cf4b3e27dc70add0d2244457c59604 100644 --- a/src/Database/Database.csproj +++ b/src/Database/Database.csproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="15.0"> <Import Project="..\packages\linq2db.SqlServer.2.6.4\build\linq2db.SqlServer.props" Condition="Exists('..\packages\linq2db.SqlServer.2.6.4\build\linq2db.SqlServer.props')" /> <Import Project="..\packages\linq2db.t4models.2.6.4\build\linq2db.t4models.props" Condition="Exists('..\packages\linq2db.t4models.2.6.4\build\linq2db.t4models.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> @@ -33,12 +33,18 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> + <PropertyGroup> + <SignAssembly>true</SignAssembly> + </PropertyGroup> + <PropertyGroup> + <AssemblyOriginatorKeyFile>Coscine.Database.Key.snk</AssemblyOriginatorKeyFile> + </PropertyGroup> <ItemGroup> <Reference Include="Consul, Version=0.7.2.6, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL"> <HintPath>..\packages\Consul.0.7.2.6\lib\net45\Consul.dll</HintPath> </Reference> - <Reference Include="Coscine.Configuration"> - <HintPath>..\lib\Coscine.Configuration.dll</HintPath> + <Reference Include="Coscine.Configuration, Version=1.3.1.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL"> + <HintPath>..\packages\Coscine.Configuration.1.3.1\lib\net461\Coscine.Configuration.dll</HintPath> </Reference> <Reference Include="linq2db, Version=2.6.4.0, Culture=neutral, PublicKeyToken=e41013125f9e410a, processorArchitecture=MSIL"> <HintPath>..\packages\linq2db.2.6.4\lib\net46\linq2db.dll</HintPath> @@ -55,35 +61,26 @@ </ItemGroup> <Import Project="CustomT4.targets" /> <ItemGroup> + <None Include="Coscine.Database.Key.snk" /> <None Include="CustomT4.targets" /> - <None Include="DatabaseConnection.ttinclude"> - <Generator>TextTemplatingFileGenerator</Generator> + <None Include="DatabaseConnection.t4"> <LastGenOutput>DatabaseConnection.generated.cs</LastGenOutput> </None> - <Compile Include="DataModel\CsDatabase.generated.cs" /> + <None Include="DataModelConstructor.t4"> + <LastGenOutput>DataModelConstructor1.generated.cs</LastGenOutput> + </None> + <Compile Include="DataModel\CsDatabase.generated.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>CsDatabase.tt</DependentUpon> + </Compile> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> - <None Include="DataModelConstructor.ttinclude"> - <Generator>TextTemplatingFileGenerator</Generator> - <LastGenOutput>DataModelConstructor.cs</LastGenOutput> - </None> <Content Include="DataModel\CsDatabase.tt"> <Generator>TextTemplatingFileGenerator</Generator> - <LastGenOutput>CsDatabase1.generated.cs</LastGenOutput> + <LastGenOutput>CsDatabase.generated.cs</LastGenOutput> </Content> - <Content Include="LinqToDB.Templates\CopyMe.Access.tt.txt" /> - <Content Include="LinqToDB.Templates\CopyMe.DB2.tt.txt" /> - <Content Include="LinqToDB.Templates\CopyMe.Firebird.tt.txt" /> - <Content Include="LinqToDB.Templates\CopyMe.Informix.tt.txt" /> - <Content Include="LinqToDB.Templates\CopyMe.MySql.tt.txt" /> - <Content Include="LinqToDB.Templates\CopyMe.Oracle.tt.txt" /> - <Content Include="LinqToDB.Templates\CopyMe.PostgreSQL.tt.txt" /> - <Content Include="LinqToDB.Templates\CopyMe.SapHana.tt.txt" /> - <Content Include="LinqToDB.Templates\CopyMe.SqlCe.tt.txt" /> - <Content Include="LinqToDB.Templates\CopyMe.SQLite.tt.txt" /> - <Content Include="LinqToDB.Templates\CopyMe.SqlServer.tt.txt" /> - <Content Include="LinqToDB.Templates\CopyMe.Sybase.tt.txt" /> </ItemGroup> <ItemGroup> <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> @@ -150,8 +147,7 @@ <LinqToDBT4ToolsDirectory>$(MSBuildProjectDirectory)\..\.tools\linq2db.t4models\</LinqToDBT4ToolsDirectory> </PropertyGroup> <PropertyGroup> - <PreBuildEvent> - </PreBuildEvent> + <PreBuildEvent /> </PropertyGroup> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> diff --git a/src/Database/Database.nuspec b/src/Database/Database.nuspec new file mode 100644 index 0000000000000000000000000000000000000000..07684ca242551c84069d1ce80308c596f6da7e13 --- /dev/null +++ b/src/Database/Database.nuspec @@ -0,0 +1,15 @@ +<?xml version="1.0"?> +<package > + <metadata> + <id>$id$</id> + <version>$version$</version> + <title>$title$</title> + <authors>rwth-aachen</authors> + <owners>rwth-aachen</owners> + <license type="expression">MIT</license> + <projectUrl>https://git.rwth-aachen.de/coscine/cs/database</projectUrl> + <requireLicenseAcceptance>true</requireLicenseAcceptance> + <description>$description$</description> + <copyright>$copyright$</copyright> + </metadata> +</package> \ No newline at end of file diff --git a/src/Database/DatabaseConnection.cs b/src/Database/DatabaseConnection.cs deleted file mode 100644 index c65238fb38a1938a8e8c4396432f1092cc79e8f1..0000000000000000000000000000000000000000 --- a/src/Database/DatabaseConnection.cs +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/Database/DatabaseConnection.t4 b/src/Database/DatabaseConnection.t4 new file mode 100644 index 0000000000000000000000000000000000000000..e490f2400068d161f4ff29e693f9114e89e2c1dd --- /dev/null +++ b/src/Database/DatabaseConnection.t4 @@ -0,0 +1,26 @@ +<#@ assembly name="$(ProjectDir)..\packages\Coscine.Configuration.1.3.0\lib\net461\Coscine.Configuration.dll"#> +<#@ import namespace="Coscine.Configuration" #> +<#@ assembly name="$(ProjectDir)..\packages\Consul.0.7.2.6\lib\net45\Consul.dll"#> +<#@ import namespace="Consul" #> + +<# NamespaceName = "Coscine.Database.Model"; #> +<#+ + class DatabaseConnection + { + private readonly string _DB_DATA_SOURCE_KEY = "coscine/global/db_data_source"; + private readonly string _DB_NAME_KEY = "coscine/global/db_name"; + private readonly string _DB_USER_ID_KEY = "coscine/global/db_user_id"; + private readonly string _DB_PASSWORD_KEY = "coscine/global/db_password"; + + public string[] GetConnectionKeys() + { + var configuration = new Coscine.Configuration.ConsulConfiguration(); + var connection_keys = new string[4]; + connection_keys[0] = configuration.GetString(_DB_DATA_SOURCE_KEY); + connection_keys[1] = configuration.GetString(_DB_NAME_KEY); + connection_keys[2] = configuration.GetString(_DB_USER_ID_KEY); + connection_keys[3] = configuration.GetString(_DB_PASSWORD_KEY); + return connection_keys; + } + } +#> \ No newline at end of file diff --git a/src/Database/DatabaseConnection.ttinclude b/src/Database/DatabaseConnection.ttinclude deleted file mode 100644 index d6c4a6c1329b2fbe5251fa964fed64f40d33c6d2..0000000000000000000000000000000000000000 --- a/src/Database/DatabaseConnection.ttinclude +++ /dev/null @@ -1,29 +0,0 @@ -<#@ assembly name="$(ProjectDir)..\lib\Coscine.Configuration.dll" #> -<#@ import namespace="Coscine.Configuration" #> - - -<#+ - class DatabaseConnection - { - string DB_DATA_SOURCE_KEY = "coscine/global/db_data_source"; - string DB_NAME_KEY = "coscine/global/db_name"; - string DB_USER_ID_KEY = "coscine/global/db_user_id"; - string DB_PASSWORD_KEY = "coscine/global/db_password"; - - - public string[] GetConnectionKeys() - { - Coscine.Configuration.IConfiguration configuration = new Coscine.Configuration.ConsulConfiguration(); - string[] connection_keys = new string[4]; - var dbDataSource = configuration.GetString(DB_DATA_SOURCE_KEY); - var dbDatabase = configuration.GetString(DB_NAME_KEY); - var dbUserId = configuration.GetString(DB_USER_ID_KEY); - var dbPassword = configuration.GetString(DB_PASSWORD_KEY); - connection_keys[0] = dbDataSource; - connection_keys[1] = dbDatabase; - connection_keys[2] = dbUserId; - connection_keys[3] = dbPassword; - return connection_keys; - } - } -#> \ No newline at end of file diff --git a/src/Database/LinqToDB.Templates/CopyMe.Access.tt.txt b/src/Database/LinqToDB.Templates/CopyMe.Access.tt.txt deleted file mode 100644 index 01f9aed963515d8a1ae1cf6e091b0253dae602ae..0000000000000000000000000000000000000000 --- a/src/Database/LinqToDB.Templates/CopyMe.Access.tt.txt +++ /dev/null @@ -1,46 +0,0 @@ -<#@ template language="C#" debug="True" hostSpecific="True" #> -<#@ output extension=".generated.cs" #> -<#@ include file="$(LinqToDBT4AccessTemplatesDirectory)LinqToDB.Access.Tools.ttinclude" #> -<#@ include file="$(LinqToDBT4AccessTemplatesDirectory)PluralizationService.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.Access.Tools.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> -<# - /* - 1. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model - and copy content from this file to it. For example: - - MyProject - DataModels - MyDatabase.tt - - 2. Modify the connection settings below to connect to your database. - - 3. Add connection string to the web/app.config file: - - <connectionStrings> - <add name="MyDatabase" providerName="Access" - connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MyDatabase.mdb;Locale Identifier=1033;Jet OLEDB:Engine Type=5;Persist Security Info=True" /> - </connectionStrings> - - 4. To access your database use the following code: - - using (var db = new MyDatabaseDB()) - { - var q = - from c in db.Customers - select c; - - foreach (var c in q) - Console.WriteLine(c.ContactName); - } - - 5. See more at https://github.com/linq2db/t4models - */ - - NamespaceName = "DataModels"; - - LoadAccessMetadata(@"C:\Data", "MyDatabase.mdb"); -// LoadAccessMetadata(string connectionString); - - GenerateModel(); -#> diff --git a/src/Database/LinqToDB.Templates/CopyMe.DB2.tt.txt b/src/Database/LinqToDB.Templates/CopyMe.DB2.tt.txt deleted file mode 100644 index 611011da4fed824c029df80fdab44e53a60b8f49..0000000000000000000000000000000000000000 --- a/src/Database/LinqToDB.Templates/CopyMe.DB2.tt.txt +++ /dev/null @@ -1,50 +0,0 @@ -<#@ template language="C#" debug="True" hostSpecific="True" #> -<#@ output extension=".generated.cs" #> -<#@ include file="$(LinqToDBT4DB2TemplatesDirectory)LinqToDB.DB2.Tools.ttinclude" #> -<#@ include file="$(LinqToDBT4DB2TemplatesDirectory)PluralizationService.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.DB2.Tools.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> -<# - /* - 1. Download and install IBM Data Server Provider for .NET. - - 2. Add a reference to IBM.Data.DB2.dll. - - 3. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model - and copy content from this file to it. For example: - - MyProject - DataModels - MyDatabase.tt - - 4. Modify the connection settings below to connect to your database. - - 5. Add connection string to the web/app.config file: - - <connectionStrings> - <add name="MyDatabase" providerName="DB2" - connectionString="Server=MyServer:50000;Database=MyDatabase;UID=MyUser;PWD=TestPassword;" /> - </connectionStrings> - - 6. To access your database use the following code: - - using (var db = new MyDatabaseDB()) - { - var q = - from c in db.Customers - select c; - - foreach (var c in q) - Console.WriteLine(c.ContactName); - } - - 7. See more at https://github.com/linq2db/t4models - */ - - NamespaceName = "DataModels"; - - LoadDB2Metadata("MyServer", "50000", "MyDatabase", "MyUser", "TestPassword"); -// LoadDB2Metadata(string connectionString); - - GenerateModel(); -#> diff --git a/src/Database/LinqToDB.Templates/CopyMe.Firebird.tt.txt b/src/Database/LinqToDB.Templates/CopyMe.Firebird.tt.txt deleted file mode 100644 index f3d2559e053ba0ba0340d4e1dcf86f99f610598a..0000000000000000000000000000000000000000 --- a/src/Database/LinqToDB.Templates/CopyMe.Firebird.tt.txt +++ /dev/null @@ -1,46 +0,0 @@ -<#@ template language="C#" debug="True" hostSpecific="True" #> -<#@ output extension=".generated.cs" #> -<#@ include file="$(LinqToDBT4FirebirdTemplatesDirectory)LinqToDB.Firebird.Tools.ttinclude" #> -<#@ include file="$(LinqToDBT4FirebirdTemplatesDirectory)PluralizationService.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.Firebird.Tools.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> -<# - /* - 1. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model - and copy content from this file to it. For example: - - MyProject - DataModels - MyDatabase.tt - - 2. Modify the connection settings below to connect to your database. - - 3. Add connection string to the web/app.config file: - - <connectionStrings> - <add name="MyDatabase" connectionString="DataSource=MyServer;Database=C:\Data\MyDatabase.fdb;User Id=SYSDBA;Password=masterkey" providerName="Firebird" /> - </connectionStrings> - - 4. To access your database use the following code: - - using (var db = new MyDatabaseDB()) - { - var q = - from c in db.Customers - select c; - - foreach (var c in q) - Console.WriteLine(c.ContactName); - } - - 5. See more at https://github.com/linq2db/t4models - */ - - NamespaceName = "DataModels"; - - LoadFirebirdMetadata("MyServer", @"C:\Data\MyDatabase.fdb"); -// LoadFirebirdMetadata(string server, string database, string uid, string password); -// LoadFirebirdMetadata(string connectionString); - - GenerateModel(); -#> diff --git a/src/Database/LinqToDB.Templates/CopyMe.Informix.tt.txt b/src/Database/LinqToDB.Templates/CopyMe.Informix.tt.txt deleted file mode 100644 index 17acc1fc73fd405e8fc72106fb3859d9f4dc9ce6..0000000000000000000000000000000000000000 --- a/src/Database/LinqToDB.Templates/CopyMe.Informix.tt.txt +++ /dev/null @@ -1,51 +0,0 @@ -<#@ template language="C#" debug="True" hostSpecific="True" #> -<#@ output extension=".generated.cs" #> -<#@ include file="$(LinqToDBT4InformixTemplatesDirectory)LinqToDB.Informix.Tools.ttinclude" #> -<#@ include file="$(LinqToDBT4InformixTemplatesDirectory)PluralizationService.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.Informix.Tools.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> -<# - /* - 1. Download and install IBM Data Server Provider for .NET. - - 2. Add a reference to IBM.Data.Informix.dll. - - 3. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model - and copy content from this file to it. For example: - - MyProject - DataModels - MyDatabase.tt - - 4. Modify the connection settings below to connect to your database. - - 5. Add connection string to the web/app.config file: - - <connectionStrings> - <add name="MyDatabase" - connectionString="Host=MyServer;Service=9088;Server=ol_informix1170;Protocol=onsoctcp;Database=MyDatabase;UID=informix;PWD=TestPassword;" - providerName="IBM.Data.Informix"/> - </connectionStrings> - - 6. To access your database use the following code: - - using (var db = new MyDatabaseDB()) - { - var q = - from c in db.Customers - select c; - - foreach (var c in q) - Console.WriteLine(c.ContactName); - } - - 7. See more at https://github.com/linq2db/t4models - */ - - NamespaceName = "DataModels"; - - LoadInformixMetadata("MyServer", "9088", "ol_informix1170", "MyDatabase", "informix", "TestPassword"); -// LoadInformixMetadata(string connectionString); - - GenerateModel(); -#> diff --git a/src/Database/LinqToDB.Templates/CopyMe.MySql.tt.txt b/src/Database/LinqToDB.Templates/CopyMe.MySql.tt.txt deleted file mode 100644 index 173d74fa74253225d96a9fe552999988d1247b1d..0000000000000000000000000000000000000000 --- a/src/Database/LinqToDB.Templates/CopyMe.MySql.tt.txt +++ /dev/null @@ -1,45 +0,0 @@ -<#@ template language="C#" debug="True" hostSpecific="True" #> -<#@ output extension=".generated.cs" #> -<#@ include file="$(LinqToDBT4MySqlTemplatesDirectory)LinqToDB.MySql.Tools.ttinclude" #> -<#@ include file="$(LinqToDBT4MySqlTemplatesDirectory)PluralizationService.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.MySql.Tools.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> -<# - /* - 1. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model - and copy content from this file to it. For example: - - MyProject - DataModels - MyDatabase.tt - - 2. Modify the connection settings below to connect to your database. - - 3. Add connection string to the web/app.config file: - - <connectionStrings> - <add name="MyDatabase" connectionString="Server=MyServer;Port=3306;Database=MyDatabase;Uid=root;Pwd=TestPassword;charset=utf8;" providerName="MySql.Data.MySqlClient" /> - </connectionStrings> - - 4. To access your database use the following code: - - using (var db = new MyDatabaseDB()) - { - var q = - from c in db.Customers - select c; - - foreach (var c in q) - Console.WriteLine(c.ContactName); - } - - 5. See more at https://github.com/linq2db/t4models - */ - - NamespaceName = "DataModels"; - - LoadMySqlMetadata("MyServer", "MyDatabase", "root", "TestPassword"); -// LoadMySqlMetadata(string connectionString); - - GenerateModel(); -#> diff --git a/src/Database/LinqToDB.Templates/CopyMe.Oracle.tt.txt b/src/Database/LinqToDB.Templates/CopyMe.Oracle.tt.txt deleted file mode 100644 index 16b17cab5f4bd5b3468af299008663b363e19ea8..0000000000000000000000000000000000000000 --- a/src/Database/LinqToDB.Templates/CopyMe.Oracle.tt.txt +++ /dev/null @@ -1,45 +0,0 @@ -<#@ template language="C#" debug="True" hostSpecific="True" #> -<#@ output extension=".generated.cs" #> -<#@ include file="$(LinqToDBT4OracleTemplatesDirectory)LinqToDB.Oracle.Tools.ttinclude" #> -<#@ include file="$(LinqToDBT4OracleTemplatesDirectory)PluralizationService.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.Oracle.Tools.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> -<# - /* - 1. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model - and copy content from this file to it. For example: - - MyProject - DataModels - MyDatabase.tt - - 2. Modify the connection settings below to connect to your database. - - 3. Add connection string to the web/app.config file: - - <connectionStrings> - <add name="MyDatabase" connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyServer)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MyDatabase)));User Id=MyUser;Password=MyPassword;" providerName="Oracle" /> - </connectionStrings> - - 4. To access your database use the following code: - - using (var db = new MyDatabaseDB()) - { - var q = - from c in db.Customers - select c; - - foreach (var c in q) - Console.WriteLine(c.ContactName); - } - - 5. See more at https://github.com/linq2db/t4models - */ - - NamespaceName = "DataModels"; - - LoadOracleMetadata("MyServer", "1521", "MyDatabase", "MyUser", "MyPassword"); -// LoadOracleMetadata(string connectionString); - - GenerateModel(); -#> diff --git a/src/Database/LinqToDB.Templates/CopyMe.PostgreSQL.tt.txt b/src/Database/LinqToDB.Templates/CopyMe.PostgreSQL.tt.txt deleted file mode 100644 index 801611a896edbc93cd6541eaa45ae2e60cfbf936..0000000000000000000000000000000000000000 --- a/src/Database/LinqToDB.Templates/CopyMe.PostgreSQL.tt.txt +++ /dev/null @@ -1,45 +0,0 @@ -<#@ template language="C#" debug="True" hostSpecific="True" #> -<#@ output extension=".generated.cs" #> -<#@ include file="$(LinqToDBT4PostgreSQLTemplatesDirectory)LinqToDB.PostgreSQL.Tools.ttinclude" #> -<#@ include file="$(LinqToDBT4PostgreSQLTemplatesDirectory)PluralizationService.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.PostgreSQL.Tools.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> -<# - /* - 1. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model - and copy content from this file to it. For example: - - MyProject - DataModels - MyDatabase.tt - - 2. Modify the connection settings below to connect to your database. - - 3. Add connection string to the web/app.config file: - - <connectionStrings> - <add name="MyDatabase" connectionString="Server=MyServer;Port=5432;Database=MyDatabase;User Id=postgres;Password=TestPassword;Pooling=true;MinPoolSize=10;MaxPoolSize=100;Protocol=3;" providerName="PostgreSQL" /> - </connectionStrings> - - 4. To access your database use the following code: - - using (var db = new MyDatabaseDB()) - { - var q = - from c in db.Customers - select c; - - foreach (var c in q) - Console.WriteLine(c.ContactName); - } - - 5. See more at https://github.com/linq2db/t4models - */ - - NamespaceName = "DataModels"; - - LoadPostgreSQLMetadata("MyServer", "5432", "MyDatabase", "postgres", "TestPassword"); -// LoadPostgreSQLMetadata(string connectionString); - - GenerateModel(); -#> diff --git a/src/Database/LinqToDB.Templates/CopyMe.SQLite.tt.txt b/src/Database/LinqToDB.Templates/CopyMe.SQLite.tt.txt deleted file mode 100644 index d0d8f08812059acae99cf83bc735018f97f2de3a..0000000000000000000000000000000000000000 --- a/src/Database/LinqToDB.Templates/CopyMe.SQLite.tt.txt +++ /dev/null @@ -1,45 +0,0 @@ -<#@ template language="C#" debug="True" hostSpecific="True" #> -<#@ output extension=".generated.cs" #> -<#@ include file="$(LinqToDBT4SQLiteTemplatesDirectory)LinqToDB.SQLite.Tools.ttinclude" #> -<#@ include file="$(LinqToDBT4SQLiteTemplatesDirectory)PluralizationService.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.SQLite.Tools.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> -<# - /* - 1. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model - and copy content from this file to it. For example: - - MyProject - DataModels - MyDatabase.tt - - 2. Modify the connection settings below to connect to your database. - - 3. Add connection string to the web/app.config file: - - <connectionStrings> - <add name="MyDatabase" connectionString="Data Source=MyDatabase.sqlite" providerName="SQLite" /> - </connectionStrings> - - 4. To access your database use the following code: - - using (var db = new MyDatabaseDB()) - { - var q = - from c in db.Customers - select c; - - foreach (var c in q) - Console.WriteLine(c.ContactName); - } - - 5. See more at https://github.com/linq2db/t4models - */ - - NamespaceName = "DataModels"; - - LoadSQLiteMetadata(@"C:\Data", "MyDatabase.sqlite"); -// LoadSQLiteMetadata(string connectionString); - - GenerateModel(); -#> diff --git a/src/Database/LinqToDB.Templates/CopyMe.SapHana.tt.txt b/src/Database/LinqToDB.Templates/CopyMe.SapHana.tt.txt deleted file mode 100644 index 7c79bf9e504ab5f80552069e9f34c8cf343f7a78..0000000000000000000000000000000000000000 --- a/src/Database/LinqToDB.Templates/CopyMe.SapHana.tt.txt +++ /dev/null @@ -1,49 +0,0 @@ -<#@ template language="C#" debug="True" hostSpecific="True" #> -<#@ output extension=".generated.cs" #> -<#@ include file="$(LinqToDBT4SapHanaTemplatesDirectory)LinqToDB.SapHana.Tools.ttinclude" #> -<#@ include file="$(LinqToDBT4SapHanaTemplatesDirectory)PluralizationService.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.SapHana.Tools.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> -<# - /* - 1. Download and install SapHana data provider for .NET. - - 2. Add a reference to Sap.Data.Hana.dll. - - 3. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model - and copy content from this file to it. For example: - - MyProject - DataModels - MyDatabase.tt - - 4. Modify the connection settings below to connect to your database. - - 5. Add connection string to the web/app.config file: - - <connectionStrings> - <add name="MyDatabase" connectionString="Server=hanahost:port;Current Schema=TEST;UserID=Test;Password=TestPassword;" providerName="Sap.Data.Hana" /> - </connectionStrings> - - 6. To access your database use the following code: - - using (var db = new MyDatabaseDB()) - { - var q = - from c in db.Customers - select c; - - foreach (var c in q) - Console.WriteLine(c.ContactName); - } - - 7. See more at https://github.com/linq2db/t4models - */ - - NamespaceName = "DataModels"; - - LoadSapHanaMetadata("MyServer", "MyDatabase", "TestUser", "TestPassword"); -// LoadSapHanaMetadata(string connectionString); - - GenerateModel(); -#> diff --git a/src/Database/LinqToDB.Templates/CopyMe.SqlCe.tt.txt b/src/Database/LinqToDB.Templates/CopyMe.SqlCe.tt.txt deleted file mode 100644 index 386b3a0b29c496403ff67f1dc7b99ca14b2293bc..0000000000000000000000000000000000000000 --- a/src/Database/LinqToDB.Templates/CopyMe.SqlCe.tt.txt +++ /dev/null @@ -1,45 +0,0 @@ -<#@ template language="C#" debug="True" hostSpecific="True" #> -<#@ output extension=".generated.cs" #> -<#@ include file="$(LinqToDBT4SqlCeTemplatesDirectory)LinqToDB.SqlCe.Tools.ttinclude" #> -<#@ include file="$(LinqToDBT4SqlCeTemplatesDirectory)PluralizationService.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.SqlCe.Tools.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> -<# - /* - 1. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model - and copy content from this file to it. For example: - - MyProject - DataModels - MyDatabase.tt - - 2. Modify the connection settings below to connect to your database. - - 3. Add connection string to the web/app.config file: - - <connectionStrings> - <add name="MyDatabase" connectionString="Data Source=MyDatabase.sdf" providerName="System.Data.SqlServerCe" /> - </connectionStrings> - - 4. To access your database use the following code: - - using (var db = new MyDatabaseDB()) - { - var q = - from c in db.Customers - select c; - - foreach (var c in q) - Console.WriteLine(c.ContactName); - } - - 5. See more at https://github.com/linq2db/t4models - */ - - NamespaceName = "DataModels"; - - LoadSqlCeMetadata(@"C:\Data", "MyDatabase.sdf"); -// LoadSqlCeMetadata(string connectionString); - - GenerateModel(); -#> diff --git a/src/Database/LinqToDB.Templates/CopyMe.SqlServer.tt.txt b/src/Database/LinqToDB.Templates/CopyMe.SqlServer.tt.txt deleted file mode 100644 index 891b6b7b8f425a77475c43995b6d0d807b198483..0000000000000000000000000000000000000000 --- a/src/Database/LinqToDB.Templates/CopyMe.SqlServer.tt.txt +++ /dev/null @@ -1,56 +0,0 @@ -<#@ template language="C#" debug="True" hostSpecific="True" #> -<#@ output extension=".generated.cs" #> -<#@ include file="$(LinqToDBT4SqlServerTemplatesDirectory)LinqToDB.SqlServer.Tools.ttinclude" #> -<#@ include file="$(LinqToDBT4SqlServerTemplatesDirectory)PluralizationService.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.SqlServer.Tools.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> -<# - /* - 1. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model - and copy content from this file to it. For example: - - MyProject - DataModels - MyDatabase.tt - - 2. Modify the connection settings below to connect to your database. - - 3. Add connection string to the web/app.config file: - - <connectionStrings> - <add name="MyDatabase" providerName="System.Data.SqlClient" - connectionString="Data Source=.;Database=MyDatabase;User Id=User;Password=TestPassword;" /> - </connectionStrings> - - 4. To access your database use the following code: - - using (var db = new MyDatabaseDB()) - { - var q = - from c in db.Customers - select c; - - foreach (var c in q) - Console.WriteLine(c.ContactName); - } - - 5. See more at https://github.com/linq2db/t4models - - If you need to use the Microsoft.SqlServer.Types namespace, install the Microsoft.SqlServer.Types nuget, - and replace the following include at the top of this file: - - "$(ProjectDir)LinqToDB.Templates\LinqToDB.SqlServer.Tools.ttinclude" - - with - - "$(ProjectDir)LinqToDB.Templates\LinqToDB.SqlServer.SqlTypes.Tools.ttinclude" - */ - - NamespaceName = "DataModels"; - - LoadSqlServerMetadata("MyServer", "MyDatabase", "User", "Password"); -// LoadSqlServerMetadata(".", "MyDatabase"); // Integrated Security -// LoadSqlServerMetadata(string connectionString); - - GenerateModel(); -#> diff --git a/src/Database/LinqToDB.Templates/CopyMe.Sybase.tt.txt b/src/Database/LinqToDB.Templates/CopyMe.Sybase.tt.txt deleted file mode 100644 index edbad0dc74d407c83fee3c18a0d08fc5ead3f29f..0000000000000000000000000000000000000000 --- a/src/Database/LinqToDB.Templates/CopyMe.Sybase.tt.txt +++ /dev/null @@ -1,49 +0,0 @@ -<#@ template language="C#" debug="True" hostSpecific="True" #> -<#@ output extension=".generated.cs" #> -<#@ include file="$(LinqToDBT4SybaseTemplatesDirectory)LinqToDB.Sybase.Tools.ttinclude" #> -<#@ include file="$(LinqToDBT4SybaseTemplatesDirectory)PluralizationService.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.Sybase.Tools.ttinclude" #> -<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #> -<# - /* - 1. Download and install Sybase data provider for .NET. - - 2. Add a reference to Sybase.AdoNet2(4).AseClient.dll. - - 3. Create new *.tt file (e.g. MyDatabase.tt) in a folder where you would like to generate your data model - and copy content from this file to it. For example: - - MyProject - DataModels - MyDatabase.tt - - 4. Modify the connection settings below to connect to your database. - - 5. Add connection string to the web/app.config file: - - <connectionStrings> - <add name="MyDatabase" connectionString="Data Source=MyServer;Port=5000;Database=MyDatabase;Uid=sa;Password=TestPassword;Charset=utf8;" providerName="Sybase" /> - </connectionStrings> - - 6. To access your database use the following code: - - using (var db = new MyDatabaseDB()) - { - var q = - from c in db.Customers - select c; - - foreach (var c in q) - Console.WriteLine(c.ContactName); - } - - 7. See more at https://github.com/linq2db/t4models - */ - - NamespaceName = "DataModels"; - - LoadSybaseMetadata("MyServer", "5000", "MyDatabase", "sa", "TestPassword"); -// LoadSybaseMetadata(string connectionString); - - GenerateModel(); -#> diff --git a/src/Database/packages.config b/src/Database/packages.config index 4484605a8c2a50e2ab3fa8ce9673b57d54622d31..2a94265b9195596692803a3eb793bf44e8a02110 100644 --- a/src/Database/packages.config +++ b/src/Database/packages.config @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <packages> <package id="Consul" version="0.7.2.6" targetFramework="net461" /> + <package id="Coscine.Configuration" version="1.3.1" targetFramework="net461" /> <package id="linq2db" version="2.6.4" targetFramework="net461" /> <package id="linq2db.SqlServer" version="2.6.4" targetFramework="net461" /> <package id="linq2db.t4models" version="2.6.4" targetFramework="net461" /> diff --git a/src/Migrator/Migrator.csproj b/src/Migrator/Migrator.csproj index e16a28ca74d7c290134aec491a2ee8778ee64db6..fb0974c1f05634b01c6f8a5530d43f08237f4fc7 100644 --- a/src/Migrator/Migrator.csproj +++ b/src/Migrator/Migrator.csproj @@ -38,8 +38,8 @@ <Reference Include="Consul, Version=0.7.2.6, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL"> <HintPath>..\packages\Consul.0.7.2.6\lib\net45\Consul.dll</HintPath> </Reference> - <Reference Include="Coscine.Configuration"> - <HintPath>..\lib\Coscine.Configuration.dll</HintPath> + <Reference Include="Coscine.Configuration, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\packages\Coscine.Configuration.1.3.0\lib\net461\Coscine.Configuration.dll</HintPath> </Reference> <Reference Include="FluentMigrator, Version=3.1.3.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05, processorArchitecture=MSIL"> <HintPath>..\packages\FluentMigrator.3.1.3\lib\net461\FluentMigrator.dll</HintPath> diff --git a/src/Migrator/packages.config b/src/Migrator/packages.config index 8dc337238abd29aae4af6cdd2ef4354f2b1bd7ac..a32c9bbff68906075efefd264cd3c5b4639ef97a 100644 --- a/src/Migrator/packages.config +++ b/src/Migrator/packages.config @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <packages> <package id="Consul" version="0.7.2.6" targetFramework="net461" /> + <package id="Coscine.Configuration" version="1.3.0" targetFramework="net461" /> <package id="FluentMigrator" version="3.1.3" targetFramework="net461" /> <package id="FluentMigrator.Abstractions" version="3.1.3" targetFramework="net461" /> <package id="FluentMigrator.Console" version="3.1.3" targetFramework="net461" /> diff --git a/src/lib/Consul.dll b/src/lib/Consul.dll deleted file mode 100644 index 438792009a73e14f174592b604d9dfc3211a5396..0000000000000000000000000000000000000000 Binary files a/src/lib/Consul.dll and /dev/null differ diff --git a/src/lib/Coscine.Configuration.dll b/src/lib/Coscine.Configuration.dll deleted file mode 100644 index 69195c7d41af36f4d990849f7c5a041527735f2f..0000000000000000000000000000000000000000 Binary files a/src/lib/Coscine.Configuration.dll and /dev/null differ diff --git a/tools/packages.config b/tools/packages.config new file mode 100644 index 0000000000000000000000000000000000000000..3c65df896fad902af9e0d5bc8388adf80f57944c --- /dev/null +++ b/tools/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Cake" version="0.28.0" /> +</packages>