From 4bdf20822f6f89e06d8776a9a9d678f863a664ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Helmrich?= Date: Wed, 8 Jul 2020 08:31:56 +0200 Subject: [PATCH 1/9] check whether the file is in use, dependent runtime-dlls will distribute --- .../Infrastructure/InstallationManager.cs | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/Oqtane.Server/Infrastructure/InstallationManager.cs b/Oqtane.Server/Infrastructure/InstallationManager.cs index f9a6f01c..c87665ca 100644 --- a/Oqtane.Server/Infrastructure/InstallationManager.cs +++ b/Oqtane.Server/Infrastructure/InstallationManager.cs @@ -1,13 +1,13 @@ -using System.Reflection; +using System; +using System.Diagnostics; using System.IO; using System.IO.Compression; -using Microsoft.Extensions.Hosting; -using Microsoft.AspNetCore.Hosting; +using System.Reflection; using System.Xml; -using Oqtane.Shared; -using System; -using System.Diagnostics; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Hosting; +using Oqtane.Shared; namespace Oqtane.Infrastructure { @@ -27,7 +27,7 @@ namespace Oqtane.Infrastructure public void InstallPackages(string folders, bool restart) { var webRootPath = _environment.WebRootPath; - + var install = InstallPackages(folders, webRootPath); if (install && restart) @@ -101,6 +101,11 @@ namespace Oqtane.Infrastructure filename = Path.Combine(webRootPath, Utilities.PathCombine(entry.FullName.Replace($"wwwroot{Path.DirectorySeparatorChar}", "").Split(Path.DirectorySeparatorChar))); ExtractFile(entry, filename); break; + case "runtimes": + var destSubFolder = Path.GetDirectoryName(entry.FullName); + filename = Path.Combine(binFolder, destSubFolder, filename); + ExtractFile(entry, filename); + break; } } } @@ -121,9 +126,24 @@ namespace Oqtane.Infrastructure { Directory.CreateDirectory(Path.GetDirectoryName(filename)); } - entry.ExtractToFile(filename, true); + if (FileInUse(filename) == false) + entry.ExtractToFile(filename, true); + } + private static bool FileInUse(string path) + { + try + { + using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate)) + { + var flag = fs.CanWrite; + } + return false; + } + catch (IOException ex) + { + return true; + } } - public void UpgradeFramework() { string folder = Path.Combine(_environment.WebRootPath, "Framework"); @@ -131,7 +151,7 @@ namespace Oqtane.Infrastructure { // get package with highest version and clean up any others string packagename = ""; - foreach(string package in Directory.GetFiles(folder, "Oqtane.Framework.*.nupkg")) + foreach (string package in Directory.GetFiles(folder, "Oqtane.Framework.*.nupkg")) { if (packagename != "") { From 5e1671afe308f8c614f8f7faab1c6152e354ad6c Mon Sep 17 00:00:00 2001 From: ADefWebserver Date: Fri, 17 Jul 2020 18:10:22 -0700 Subject: [PATCH 2/9] Create azuredeploy.json --- azuredeploy.json | 197 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 azuredeploy.json diff --git a/azuredeploy.json b/azuredeploy.json new file mode 100644 index 00000000..39a65f99 --- /dev/null +++ b/azuredeploy.json @@ -0,0 +1,197 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.1", + "parameters": { + "sqlServerName": { + "type": "string", + "metadata": { + "description": "The name of the sql server. It has to be unique." + } + }, + "databaseName": { + "type": "string", + "metadata": { + "description": "The name of the sql databaseName. It has to be unique." + } + }, + "sqlAdministratorLogin": { + "type": "string", + "metadata": { + "description": "The admin user of the SQL Server" + } + }, + "sqlAdministratorLoginPassword": { + "type": "securestring", + "metadata": { + "description": "The password of the admin user of the SQL Server" + } + }, + "BlazorWebsiteName": { + "type": "string", + "metadata": { + "description": "The name of the website. It has to be unique." + } + }, + "BlazorSKU": { + "type": "string", + "allowedValues": [ + "Free", + "Shared", + "Basic", + "Standard" + ], + "defaultValue": "Standard" + }, + "BlazorWorkerSize": { + "type": "string", + "allowedValues": [ + "0", + "1", + "2" + ], + "defaultValue": "0" + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]", + "metadata": { + "description": "Location for all resources." + } + } + }, + "variables": { + "hostingPlanName": "[concat('Oqtane-hostingplan-', uniqueString(resourceGroup().id))]", + "databaseEdition": "Standard", + "databaseCollation": "SQL_Latin1_General_CP1_CI_AS", + "databaseServiceObjectiveName": "Standard" + }, + "resources": [ + { + "name": "[parameters('sqlServerName')]", + "type": "Microsoft.Sql/servers", + "apiVersion": "2014-04-01", + "location": "[resourceGroup().location]", + "tags": { + "displayName": "SqlServer" + }, + "properties": { + "administratorLogin": "[parameters('sqlAdministratorLogin')]", + "administratorLoginPassword": "[parameters('sqlAdministratorLoginPassword')]", + "version": "12.0" + }, + "resources": [ + { + "name": "[parameters('databaseName')]", + "type": "databases", + "apiVersion": "2015-01-01", + "location": "[resourceGroup().location]", + "tags": { + "displayName": "Database" + }, + "properties": { + "edition": "[variables('databaseEdition')]", + "collation": "[variables('databaseCollation')]", + "requestedServiceObjectiveName": "[variables('databaseServiceObjectiveName')]" + }, + "dependsOn": [ + "[parameters('sqlServerName')]" + ], + "resources": [ + { + "comments": "Transparent Data Encryption", + "name": "current", + "type": "transparentDataEncryption", + "apiVersion": "2014-04-01-preview", + "properties": { + "status": "Enabled" + }, + "dependsOn": [ + "[parameters('databaseName')]" + ] + } + ] + }, + { + "name": "AllowAllMicrosoftAzureIps", + "type": "firewallrules", + "apiVersion": "2014-04-01", + "location": "[resourceGroup().location]", + "properties": { + "endIpAddress": "0.0.0.0", + "startIpAddress": "0.0.0.0" + }, + "dependsOn": [ + "[parameters('sqlServerName')]" + ] + } + ] + }, + { + "name": "[variables('hostingPlanName')]", + "type": "Microsoft.Web/serverfarms", + "location": "[resourceGroup().location]", + "apiVersion": "2014-06-01", + "dependsOn": [], + "tags": { + "displayName": "Blazor" + }, + "properties": { + "name": "[variables('hostingPlanName')]", + "sku": "[parameters('BlazorSKU')]", + "workerSize": "[parameters('BlazorWorkerSize')]", + "numberOfWorkers": 1 + } + }, + { + "apiVersion": "2018-02-01", + "name": "[parameters('BlazorWebsiteName')]", + "type": "Microsoft.Web/sites", + "location": "[parameters('location')]", + "dependsOn": [ + "[variables('hostingPlanName')]" + ], + "tags": { + "[concat('hidden-related:', resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName')))]": "empty", + "displayName": "Website" + }, + "properties": { + "name": "[parameters('BlazorWebsiteName')]", + "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]", + "siteConfig": { + "webSocketsEnabled": true + } + }, + "resources": [ + { + "type": "sourcecontrols", + "apiVersion": "2018-02-01", + "name": "web", + "location": "[parameters('location')]", + "dependsOn": [ + "[resourceId('Microsoft.Web/sites', parameters('BlazorWebsiteName'))]", + "[resourceId('Microsoft.Web/Sites/config', parameters('BlazorWebsiteName'), 'connectionstrings')]" + ], + "properties": { + "RepoUrl": "https://github.com/ADefWebserver/oqtane.framework.git", + "branch": "main", + "IsManualIntegration": true + } + }, + { + "apiVersion": "2018-02-01", + "type": "config", + "name": "connectionstrings", + "dependsOn": [ + "[resourceId('Microsoft.Web/sites', parameters('BlazorWebsiteName'))]" + ], + "properties": { + "DefaultConnection": { + "value": "[concat('Data Source=tcp:', reference(concat('Microsoft.Sql/servers/', parameters('sqlserverName'))).fullyQualifiedDomainName, ',1433;Initial Catalog=', parameters('databaseName'), ';User Id=', parameters('sqlAdministratorLogin'), '@', reference(concat('Microsoft.Sql/servers/', parameters('sqlserverName'))).fullyQualifiedDomainName, ';Password=', parameters('sqlAdministratorLoginPassword'), ';')]", + "type": "SQLAzure" + } + } + } + ] + } + ] +} From 7b407255347f2f4f1e76c3a38dfb0d99f80cc969 Mon Sep 17 00:00:00 2001 From: ADefWebserver Date: Fri, 17 Jul 2020 18:15:08 -0700 Subject: [PATCH 3/9] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4d5072e9..7b09ccc0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Oqtane Framework Oqtane is a Modular Application Framework for Blazor +[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FADefWebserver%2Foqtane.framework%2Fmaster%2Fazuredeploy.json) + ![Oqtane](https://github.com/oqtane/framework/blob/master/oqtane.png?raw=true "Oqtane") Oqtane uses Blazor, an open source and cross-platform web UI framework for building single-page apps using .NET and C# instead of JavaScript. Blazor apps are composed of reusable web UI components implemented using C#, HTML, and CSS. Both client and server code is written in C#, allowing you to share code and libraries. From 9fe72a1c98f47aafc52c5abf636c95723aaf1ffd Mon Sep 17 00:00:00 2001 From: ADefWebserver Date: Fri, 17 Jul 2020 18:45:57 -0700 Subject: [PATCH 4/9] Update azuredeploy.json --- azuredeploy.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azuredeploy.json b/azuredeploy.json index 39a65f99..2d2c6241 100644 --- a/azuredeploy.json +++ b/azuredeploy.json @@ -173,7 +173,7 @@ ], "properties": { "RepoUrl": "https://github.com/ADefWebserver/oqtane.framework.git", - "branch": "main", + "branch": "master", "IsManualIntegration": true } }, From 97c56ba1427031770fda14ccc842b7d6b16b72ef Mon Sep 17 00:00:00 2001 From: ADefWebserver Date: Sat, 18 Jul 2020 08:02:03 -0700 Subject: [PATCH 5/9] Create azure.deployment --- azure.deployment | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 azure.deployment diff --git a/azure.deployment b/azure.deployment new file mode 100644 index 00000000..e6e53348 --- /dev/null +++ b/azure.deployment @@ -0,0 +1,2 @@ +[config] +project = WebProject/Oqtane.sln From a65cdbd7ad2bd0946f46436a89f7d7a30c959909 Mon Sep 17 00:00:00 2001 From: ADefWebserver Date: Sat, 18 Jul 2020 08:12:18 -0700 Subject: [PATCH 6/9] Rename azure.deployment to .deployment --- azure.deployment => .deployment | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename azure.deployment => .deployment (100%) diff --git a/azure.deployment b/.deployment similarity index 100% rename from azure.deployment rename to .deployment From 11c610edf0fca367e0982a179f23639bb877a334 Mon Sep 17 00:00:00 2001 From: ADefWebserver Date: Sat, 18 Jul 2020 09:18:02 -0700 Subject: [PATCH 7/9] Update .deployment --- .deployment | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.deployment b/.deployment index e6e53348..3f3f33f2 100644 --- a/.deployment +++ b/.deployment @@ -1,2 +1,2 @@ [config] -project = WebProject/Oqtane.sln +project = Oqtane.Server/Oqtane.Server.csproj From 9eb8a7e65cf666508b1336096af418eadd0b6b84 Mon Sep 17 00:00:00 2001 From: ADefWebserver Date: Sat, 18 Jul 2020 09:40:40 -0700 Subject: [PATCH 8/9] Update azuredeploy.json --- azuredeploy.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azuredeploy.json b/azuredeploy.json index 2d2c6241..4dd651bc 100644 --- a/azuredeploy.json +++ b/azuredeploy.json @@ -172,7 +172,7 @@ "[resourceId('Microsoft.Web/Sites/config', parameters('BlazorWebsiteName'), 'connectionstrings')]" ], "properties": { - "RepoUrl": "https://github.com/ADefWebserver/oqtane.framework.git", + "RepoUrl": "https://github.com/oqtane/oqtane.framework.git", "branch": "master", "IsManualIntegration": true } From e706e8cf1fde6f23f11b738de135b8e791bf67ad Mon Sep 17 00:00:00 2001 From: ADefWebserver Date: Sat, 18 Jul 2020 09:55:27 -0700 Subject: [PATCH 9/9] Update README.md Points the button to the Oqtane repository --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7b09ccc0..21a1508e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Oqtane Framework Oqtane is a Modular Application Framework for Blazor -[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FADefWebserver%2Foqtane.framework%2Fmaster%2Fazuredeploy.json) +[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Foqtane%2Foqtane.framework%2Fmaster%2Fazuredeploy.json) ![Oqtane](https://github.com/oqtane/framework/blob/master/oqtane.png?raw=true "Oqtane")