Skip to content

Commit

Permalink
Merge pull request #111 from aspnetboilerplate/upgrade-to-abp-10.0-an…
Browse files Browse the repository at this point in the history
…d-dotnet-9

Upgrade to ABP 10.0 and .NET 9
  • Loading branch information
ismcagdas authored Nov 21, 2024
2 parents 65a8652 + 54697fa commit d89a3c4
Show file tree
Hide file tree
Showing 71 changed files with 2,957 additions and 1,306 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.0.0</Version>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
Expand All @@ -9,16 +8,13 @@
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace>AbpCompanyName.AbpProjectName</RootNamespace>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\AbpCompanyName.AbpProjectName.Core\AbpCompanyName.AbpProjectName.Core.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Abp.EntityFrameworkCore" Version="9.4.1" />
<PackageReference Include="Abp.AutoMapper" Version="9.4.1" />
<PackageReference Include="Abp.EntityFrameworkCore" Version="10.0.0" />
<PackageReference Include="Abp.AutoMapper" Version="10.0.0" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using Abp.Application.Services;

namespace AbpCompanyName.AbpProjectName
namespace AbpCompanyName.AbpProjectName;

/// <summary>
/// Derive your application services from this class.
/// </summary>
public abstract class AbpProjectNameAppServiceBase : ApplicationService
{
/// <summary>
/// Derive your application services from this class.
/// </summary>
public abstract class AbpProjectNameAppServiceBase : ApplicationService
protected AbpProjectNameAppServiceBase()
{
protected AbpProjectNameAppServiceBase()
{
LocalizationSourceName = AbpProjectNameConsts.LocalizationSourceName;
}
LocalizationSourceName = AbpProjectNameConsts.LocalizationSourceName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
using Abp.Modules;
using Abp.Reflection.Extensions;

namespace AbpCompanyName.AbpProjectName
namespace AbpCompanyName.AbpProjectName;

[DependsOn(
typeof(AbpProjectNameCoreModule),
typeof(AbpAutoMapperModule))]
public class AbpProjectNameApplicationModule : AbpModule
{
[DependsOn(
typeof(AbpProjectNameCoreModule),
typeof(AbpAutoMapperModule))]
public class AbpProjectNameApplicationModule : AbpModule
public override void Initialize()
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(typeof(AbpProjectNameApplicationModule).GetAssembly());
}
IocManager.RegisterAssemblyByConvention(typeof(AbpProjectNameApplicationModule).GetAssembly());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.0.0</Version>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
Expand All @@ -9,17 +8,14 @@
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace>AbpCompanyName.AbpProjectName</RootNamespace>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="Localization\SourceFiles\*.json" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Abp" Version="9.4.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Abp" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
</ItemGroup>

</Project>
</Project>
21 changes: 10 additions & 11 deletions src/AbpCompanyName.AbpProjectName.Core/AbpProjectNameConsts.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
namespace AbpCompanyName.AbpProjectName
namespace AbpCompanyName.AbpProjectName;

public class AbpProjectNameConsts
{
public class AbpProjectNameConsts
{
public const string LocalizationSourceName = "AbpProjectName";
public const string LocalizationSourceName = "AbpProjectName";

public const string ConnectionStringName = "Default";

public const string ConnectionStringName = "Default";

/// <summary>
/// Default pass phrase for SimpleStringCipher decrypt/encrypt operations
/// </summary>
public const string DefaultPassPhrase = "{{DEFAULT_PASS_PHRASE_HERE}}";
}
/// <summary>
/// Default pass phrase for SimpleStringCipher decrypt/encrypt operations
/// </summary>
public const string DefaultPassPhrase = "{{DEFAULT_PASS_PHRASE_HERE}}";
}
25 changes: 12 additions & 13 deletions src/AbpCompanyName.AbpProjectName.Core/AbpProjectNameCoreModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
using Abp.Reflection.Extensions;
using AbpCompanyName.AbpProjectName.Localization;

namespace AbpCompanyName.AbpProjectName
namespace AbpCompanyName.AbpProjectName;

public class AbpProjectNameCoreModule : AbpModule
{
public class AbpProjectNameCoreModule : AbpModule
public override void PreInitialize()
{
public override void PreInitialize()
{
Configuration.Auditing.IsEnabledForAnonymousUsers = true;
Configuration.Auditing.IsEnabledForAnonymousUsers = true;

AbpProjectNameLocalizationConfigurer.Configure(Configuration.Localization);

AbpProjectNameLocalizationConfigurer.Configure(Configuration.Localization);

Configuration.Settings.SettingEncryptionConfiguration.DefaultPassPhrase = AbpProjectNameConsts.DefaultPassPhrase;
}
Configuration.Settings.SettingEncryptionConfiguration.DefaultPassPhrase = AbpProjectNameConsts.DefaultPassPhrase;
}

public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(typeof(AbpProjectNameCoreModule).GetAssembly());
}
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(typeof(AbpProjectNameCoreModule).GetAssembly());
}
}
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
using System.Collections.Concurrent;
using Abp.Extensions;
using Abp.Extensions;
using Microsoft.Extensions.Configuration;
using System.Collections.Concurrent;

namespace AbpCompanyName.AbpProjectName.Configuration
namespace AbpCompanyName.AbpProjectName.Configuration;

public static class AppConfigurations
{
public static class AppConfigurations
private static readonly ConcurrentDictionary<string, IConfigurationRoot> ConfigurationCache;

static AppConfigurations()
{
private static readonly ConcurrentDictionary<string, IConfigurationRoot> ConfigurationCache;
ConfigurationCache = new ConcurrentDictionary<string, IConfigurationRoot>();
}

static AppConfigurations()
{
ConfigurationCache = new ConcurrentDictionary<string, IConfigurationRoot>();
}
public static IConfigurationRoot Get(string path, string environmentName = null)
{
var cacheKey = path + "#" + environmentName;
return ConfigurationCache.GetOrAdd(
cacheKey,
_ => BuildConfiguration(path, environmentName)
);
}

public static IConfigurationRoot Get(string path, string environmentName = null)
{
var cacheKey = path + "#" + environmentName;
return ConfigurationCache.GetOrAdd(
cacheKey,
_ => BuildConfiguration(path, environmentName)
);
}
private static IConfigurationRoot BuildConfiguration(string path, string environmentName = null)
{
var builder = new ConfigurationBuilder()
.SetBasePath(path)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

private static IConfigurationRoot BuildConfiguration(string path, string environmentName = null)
if (!environmentName.IsNullOrWhiteSpace())
{
var builder = new ConfigurationBuilder()
.SetBasePath(path)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

if (!environmentName.IsNullOrWhiteSpace())
{
builder = builder.AddJsonFile($"appsettings.{environmentName}.json", optional: true);
}

builder = builder.AddEnvironmentVariables();

return builder.Build();
builder = builder.AddJsonFile($"appsettings.{environmentName}.json", optional: true);
}

builder = builder.AddEnvironmentVariables();

return builder.Build();
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
using System.Reflection;
using Abp.Configuration.Startup;
using Abp.Configuration.Startup;
using Abp.Localization;
using Abp.Localization.Dictionaries;
using Abp.Localization.Dictionaries.Json;
using Abp.Reflection.Extensions;

namespace AbpCompanyName.AbpProjectName.Localization
namespace AbpCompanyName.AbpProjectName.Localization;

public static class AbpProjectNameLocalizationConfigurer
{
public static class AbpProjectNameLocalizationConfigurer
public static void Configure(ILocalizationConfiguration localizationConfiguration)
{
public static void Configure(ILocalizationConfiguration localizationConfiguration)
{
localizationConfiguration.Languages.Add(new LanguageInfo("en", "English", "famfamfam-flags england", isDefault: true));
localizationConfiguration.Languages.Add(new LanguageInfo("tr", "Türkçe", "famfamfam-flags tr"));
localizationConfiguration.Languages.Add(new LanguageInfo("en", "English", "famfamfam-flags england", isDefault: true));
localizationConfiguration.Languages.Add(new LanguageInfo("tr", "Türkçe", "famfamfam-flags tr"));

localizationConfiguration.Sources.Add(
new DictionaryBasedLocalizationSource(AbpProjectNameConsts.LocalizationSourceName,
new JsonEmbeddedFileLocalizationDictionaryProvider(
typeof(AbpProjectNameLocalizationConfigurer).GetAssembly(),
"AbpCompanyName.AbpProjectName.Localization.SourceFiles"
)
localizationConfiguration.Sources.Add(
new DictionaryBasedLocalizationSource(AbpProjectNameConsts.LocalizationSourceName,
new JsonEmbeddedFileLocalizationDictionaryProvider(
typeof(AbpProjectNameLocalizationConfigurer).GetAssembly(),
"AbpCompanyName.AbpProjectName.Localization.SourceFiles"
)
);
}
)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,38 @@
using System.IO;
using System.Linq;

namespace AbpCompanyName.AbpProjectName.Web
namespace AbpCompanyName.AbpProjectName.Web;

/// <summary>
/// This class is used to find root path of the web project in;
/// unit tests (to find views) and entity framework core command line commands (to find conn string).
/// </summary>
public static class WebContentDirectoryFinder
{
/// <summary>
/// This class is used to find root path of the web project in;
/// unit tests (to find views) and entity framework core command line commands (to find conn string).
/// </summary>
public static class WebContentDirectoryFinder
public static string CalculateContentRootFolder()
{
public static string CalculateContentRootFolder()
var coreAssemblyDirectoryPath = Path.GetDirectoryName(AppContext.BaseDirectory);
if (coreAssemblyDirectoryPath == null)
{
var coreAssemblyDirectoryPath = Path.GetDirectoryName(AppContext.BaseDirectory);
if (coreAssemblyDirectoryPath == null)
{
throw new Exception("Could not find location of AbpCompanyName.AbpProjectName.Core assembly!");
}
throw new Exception("Could not find location of AbpCompanyName.AbpProjectName.Core assembly!");
}

var directoryInfo = new DirectoryInfo(coreAssemblyDirectoryPath);
while (!DirectoryContains(directoryInfo.FullName, "AbpCompanyName.AbpProjectName.sln"))
var directoryInfo = new DirectoryInfo(coreAssemblyDirectoryPath);
while (!DirectoryContains(directoryInfo.FullName, "AbpCompanyName.AbpProjectName.sln"))
{
if (directoryInfo.Parent == null)
{
if (directoryInfo.Parent == null)
{
throw new Exception("Could not find content root folder!");
}

directoryInfo = directoryInfo.Parent;
throw new Exception("Could not find content root folder!");
}

return Path.Combine(directoryInfo.FullName, $"src{Path.DirectorySeparatorChar}AbpCompanyName.AbpProjectName.Web");
directoryInfo = directoryInfo.Parent;
}

private static bool DirectoryContains(string directory, string fileName)
{
return Directory.GetFiles(directory).Any(filePath => string.Equals(Path.GetFileName(filePath), fileName));
}
return Path.Combine(directoryInfo.FullName, $"src{Path.DirectorySeparatorChar}AbpCompanyName.AbpProjectName.Web");
}

private static bool DirectoryContains(string directory, string fileName)
{
return Directory.GetFiles(directory).Any(filePath => string.Equals(Path.GetFileName(filePath), fileName));
}
}
Loading

0 comments on commit d89a3c4

Please sign in to comment.