diff --git a/docs/en/Autofac-Integration.md b/docs/en/Autofac-Integration.md index 1313d2c482..d05412c94b 100644 --- a/docs/en/Autofac-Integration.md +++ b/docs/en/Autofac-Integration.md @@ -1,12 +1,12 @@ # Autofac Integration -Autofac is one of the most used dependency injection frameworks for .Net. It provides some advanced features compared to .Net Core standard DI library, like dynamic proxying and property injection. +[Autofac](https://autofac.org/) is one of the most used dependency injection frameworks for .NET. It provides advanced features compared to .Net Core's standard DI library, like dynamic proxying and property injection. ## Install Autofac Integration -> All startup templates and samples are Autofac integrated. So, most of the time you don't need to manually install this package. +> All the [startup templates](Startup-Templates/Index.md) and samples are Autofac integrated. So, most of the time you don't need to manually install this package. -Install [Volo.Abp.Autofac](https://www.nuget.org/packages/Volo.Abp.Autofac) nuget package to your project (for a multi-projects application, it's suggested to add to the executable/web project.) +Install [Volo.Abp.Autofac](https://www.nuget.org/packages/Volo.Abp.Autofac) nuget package to your project (for a multi-projects application, it's suggested to add to the executable/web project). ```` Install-Package Volo.Abp.Autofac @@ -52,6 +52,23 @@ public class Program } ```` +If you are using the static `WebApplication` class, you can call the `UseAutofac()` extension method as shown below: + +````csharp +public class Program +{ + public async static Task Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + builder.Host.UseAutofac(); // Integrate Autofac! + await builder.AddApplicationAsync(); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); + } +} +```` + ### Console Application Call `UseAutofac()` method in the `AbpApplicationFactory.Create` options as shown below: @@ -79,3 +96,18 @@ namespace AbpConsoleDemo } ```` +## Using the Autofac Registration API + +If you want to use Autofac's advanced [registration API](https://autofac.readthedocs.io/en/latest/register/registration.html), you need to access the `ContainerBuilder` object. [Volo.Abp.Autofac](https://www.nuget.org/packages/Volo.Abp.Autofac) nuget package defines the `IServiceCollection.GetContainerBuilder()` extension method to obtain the `ContainerBuilder` object. + +**Example: Get the `ContainerBuilder` object in the `ConfigureServices` method of your [module class](Module-Development-Basics.md)** + +````csharp +public override void ConfigureServices(ServiceConfigurationContext context) +{ + var containerBuilder = context.Services.GetContainerBuilder(); + containerBuilder.RegisterType(); // Using Autofac's registration API +} +```` + +> You should install the [Volo.Abp.Autofac](https://www.nuget.org/packages/Volo.Abp.Autofac) nuget package to the project that you want to use the Autofac API. diff --git a/docs/en/CLI.md b/docs/en/CLI.md index 72fe0cf221..8931220705 100644 --- a/docs/en/CLI.md +++ b/docs/en/CLI.md @@ -299,7 +299,7 @@ abp generate-proxy -t [options] Examples: ````bash -abp generate-proxy -t ng +abp generate-proxy -t ng -url https://localhost:44302/ abp generate-proxy -t js -url https://localhost:44302/ abp generate-proxy -t csharp -url https://localhost:44302/ ```` @@ -313,12 +313,13 @@ abp generate-proxy -t csharp -url https://localhost:44302/ * `--api-name` or `-a`: The name of the API endpoint defined in the `/src/environments/environment.ts`. Default value: `default`. * `--source` or `-s`: Specifies the Angular project name to resolve the root namespace & API definition URL from. Default value: `defaultProject`. * `--target`: Specifies the Angular project name to place generated code in. Default value: `defaultProject`. + * `--url`: Specifies api definition url. Default value is API Name's url in environment file. * `--prompt` or `-p`: Asks the options from the command line prompt (for the unspecified options). * `js`: JavaScript. work in the `*.Web` project directory. There are some additional options for this client: * `--output` or `-o`: JavaScript file path or folder to place generated code in. * `--module` or `-m`: Specifies the name of the backend module you wish to generate proxies for. Default value: `app`. * `--working-directory` or `-wd`: Execution directory. For `csharp` and `js` client types. -* `--url` or `-u`: API definition URL from. For `csharp` and `js` client types. +* `--url` or `-u`: API definition URL from. > See the [Angular Service Proxies document](UI/Angular/Service-Proxies.md) for more. @@ -351,12 +352,13 @@ abp remove-proxy -t csharp --folder MyProxies/InnerFolder * `--api-name` or `-a`: The name of the API endpoint defined in the `/src/environments/environment.ts`. Default value: `default`. * `--source` or `-s`: Specifies the Angular project name to resolve the root namespace & API definition URL from. Default value: `defaultProject`. * `--target`: Specifies the Angular project name to place generated code in. Default value: `defaultProject`. + * `--url`: Specifies api definition url. Default value is API Name's url in environment file. * `--prompt` or `-p`: Asks the options from the command line prompt (for the unspecified options). * `js`: JavaScript. work in the `*.Web` project directory. There are some additional options for this client: * `--output` or `-o`: JavaScript file path or folder to place generated code in. * `--module` or `-m`: Specifies the name of the backend module you wish to generate proxies for. Default value: `app`. * `--working-directory` or `-wd`: Execution directory. For `csharp` and `js` client types. -* `--url` or `-u`: API definition URL from. For `csharp` and `js` client types. +* `--url` or `-u`: API definition URL from. > See the [Angular Service Proxies document](UI/Angular/Service-Proxies.md) for more. diff --git a/docs/en/Migration-Guides/Abp-5_0.md b/docs/en/Migration-Guides/Abp-5_0.md index 35780786af..758f2b91ff 100644 --- a/docs/en/Migration-Guides/Abp-5_0.md +++ b/docs/en/Migration-Guides/Abp-5_0.md @@ -117,5 +117,5 @@ db.AbpUsers.updateMany({},{$set:{ IsActive : true }}) ## See Also * [Angular UI 4.x to 5.0 Migration Guide](Abp-5_0-Angular.md) -* [ASP.NET Core MVC / Razor Pages UI 4.x to 5.0 Migration Guide]() +* [ASP.NET Core MVC / Razor Pages UI 4.x to 5.0 Migration Guide](Abp-5-0-MVC.md) * [Blazor UI 4.x to 5.0 Migration Guide](Abp-5-0-Blazor.md) diff --git a/docs/en/Migration-Guides/Index.md b/docs/en/Migration-Guides/Index.md index e2647d8b0e..17e4d70dd8 100644 --- a/docs/en/Migration-Guides/Index.md +++ b/docs/en/Migration-Guides/Index.md @@ -1,5 +1,7 @@ # ABP Framework Migration Guides +The following documents explain how to migrate your existing ABP applications. We write migration documents only if you need to take an action while upgrading your solution. Otherwise, you can easily upgrade your solution using the [abp update command](../Upgrading.md). + - [5.1 to 5.2](Abp-5_2.md) - [4.x to 5.0](Abp-5_0.md) - [4.2 to 4.3](Abp-4_3.md) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateAppSettingsSecretsStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateAppSettingsSecretsStep.cs index 7a5f792b15..20e4f8fca6 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateAppSettingsSecretsStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateAppSettingsSecretsStep.cs @@ -30,7 +30,9 @@ public class CreateAppSettingsSecretsStep : ProjectBuildPipelineStep ); } - var projectFiles = context.Files.Where(x => x.Content.Contains(AppSettingsPlaceholder)).ToList(); + var projectFiles = context.Files.Where(x => + x.Name.EndsWith(".csproj") && + x.Content.Contains(AppSettingsPlaceholder)).ToList(); foreach (var projectFile in projectFiles) { @@ -66,11 +68,30 @@ public class CreateAppSettingsSecretsStep : ProjectBuildPipelineStep private static string ReplaceAppSettingsSecretsPlaceholder(string content) { - var replaceContent = $"{Environment.NewLine}" + - $" {Environment.NewLine}" + + var path = string.Empty; + + var appSettingsRemoveLine = content.SplitToLines().FirstOrDefault(l=> + l.Contains("None") && + l.Contains("Remove") && + l.Contains(CliConsts.AppSettingsJsonFileName)); + + if (appSettingsRemoveLine != null) + { + var prefix = appSettingsRemoveLine.Split("\"") + .Select(s => s.Trim()) + .First(s => s.Contains(CliConsts.AppSettingsJsonFileName)) + .Replace(CliConsts.AppSettingsJsonFileName, ""); + + path = string.IsNullOrWhiteSpace(prefix) ? string.Empty : prefix; + } + + + var replaceContent = $"{Environment.NewLine}" + + $" {Environment.NewLine}" + $" PreserveNewest{Environment.NewLine}" + $" Always{Environment.NewLine}" + " "; + return content.Replace(AppSettingsPlaceholder, replaceContent); } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs index e6069981da..7e30a9a6bf 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs @@ -48,7 +48,7 @@ public class AngularServiceProxyGenerator : ServiceProxyGeneratorBase { const source = await resolveProject(host, params.source!); - const sourceUrl = getSourceUrl(host, source, apiName); + if (!sourceUrl) { + sourceUrl = getSourceUrl(host, source, apiName); + } return await getApiDefinition(sourceUrl); }; }