Browse Source

Merge pull request #12375 from abpframework/auto-merge/rel-5-2/1013

Merge branch dev with rel-5.2
pull/12377/head
liangshiwei 4 years ago
committed by GitHub
parent
commit
12adf12109
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 38
      docs/en/Autofac-Integration.md
  2. 8
      docs/en/CLI.md
  3. 2
      docs/en/Migration-Guides/Abp-5_0.md
  4. 2
      docs/en/Migration-Guides/Index.md
  5. 27
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateAppSettingsSecretsStep.cs
  6. 7
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs
  7. 2
      modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatureDefinitionProvider.cs
  8. 9
      npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json
  9. 9
      npm/ng-packs/packages/schematics/src/commands/proxy-refresh/schema.json
  10. 9
      npm/ng-packs/packages/schematics/src/commands/proxy-remove/schema.json
  11. 5
      npm/ng-packs/packages/schematics/src/models/generate-proxy-schema.ts
  12. 5
      npm/ng-packs/packages/schematics/src/utils/source.ts

38
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<MyProjectNameWebModule>();
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<MyService>(); // 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.

8
docs/en/CLI.md

@ -299,7 +299,7 @@ abp generate-proxy -t <client-type> [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.

2
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)

2
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)

27
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 = $"<None Remove=\"{CliConsts.AppSettingsSecretJsonFileName}\" />{Environment.NewLine}" +
$" <Content Include=\"{CliConsts.AppSettingsSecretJsonFileName}\">{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 = $"<None Remove=\"{ path + CliConsts.AppSettingsSecretJsonFileName}\" />{Environment.NewLine}" +
$" <Content Include=\"{path + CliConsts.AppSettingsSecretJsonFileName}\">{Environment.NewLine}" +
$" <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>{Environment.NewLine}" +
$" <CopyToOutputDirectory>Always</CopyToOutputDirectory>{Environment.NewLine}" +
" </Content>";
return content.Replace(AppSettingsPlaceholder, replaceContent);
}
}

7
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs

@ -48,7 +48,7 @@ public class AngularServiceProxyGenerator : ServiceProxyGeneratorBase<AngularSer
var apiName = args.ApiName ?? defaultValue;
var source = args.Source ?? defaultValue;
var target = args.Target ?? defaultValue;
var url = args.Url ?? string.Empty;
var commandBuilder = new StringBuilder("npx ng g @abp/ng.schematics:" + schematicsCommandName);
if (module != null)
@ -71,6 +71,11 @@ public class AngularServiceProxyGenerator : ServiceProxyGeneratorBase<AngularSer
commandBuilder.Append($" --target {target}");
}
if (url != null)
{
commandBuilder.Append($" --url {url}");
}
_cmdhelper.RunCmd(commandBuilder.ToString());
}

2
modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingManagementFeatureDefinitionProvider.cs

@ -23,7 +23,7 @@ public class SettingManagementFeatureDefinitionProvider : FeatureDefinitionProvi
SettingManagementFeatures.AllowTenantsToChangeEmailSettings,
"false",
L("Feature:AllowTenantsToChangeEmailSettings"),
L("AllowTenantsToChangeEmailSettingsDescription"),
L("Feature:AllowTenantsToChangeEmailSettingsDescription"),
new ToggleStringValueType(),
isAvailableToHost: false);
}

9
npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json

@ -39,6 +39,15 @@
"index": 3
},
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
},
"url": {
"description": "Url for API definition",
"type": "string",
"$default": {
"$source": "argv",
"index": 4
},
"x-prompt": "Please enter URL for API definition (default: API Name's url in environment file)"
}
},
"required": []

9
npm/ng-packs/packages/schematics/src/commands/proxy-refresh/schema.json

@ -39,6 +39,15 @@
"index": 3
},
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
},
"url": {
"description": "API definition URL from",
"type": "string",
"$default": {
"$source": "argv",
"index": 4
},
"x-prompt": "Please enter URL for api definition (default: API Name's url in environment file)"
}
},
"required": []

9
npm/ng-packs/packages/schematics/src/commands/proxy-remove/schema.json

@ -39,6 +39,15 @@
"index": 3
},
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
},
"url": {
"description": "Url for API definition",
"type": "string",
"$default": {
"$source": "argv",
"index": 4
},
"x-prompt": "Please enter URL for API definition (default: API Name's url in environment file)"
}
},
"required": []

5
npm/ng-packs/packages/schematics/src/models/generate-proxy-schema.ts

@ -18,4 +18,9 @@ export interface GenerateProxySchema {
* Target Angular project to place the generated code
*/
target?: string;
/**
* Url to API definition
*/
url?: string;
}

5
npm/ng-packs/packages/schematics/src/utils/source.ts

@ -16,10 +16,13 @@ import { readEnvironment, resolveProject } from './workspace';
export function createApiDefinitionGetter(params: GenerateProxySchema) {
const apiName = params.apiName || 'default';
let sourceUrl = params.url;
return async (host: Tree) => {
const source = await resolveProject(host, params.source!);
const sourceUrl = getSourceUrl(host, source, apiName);
if (!sourceUrl) {
sourceUrl = getSourceUrl(host, source, apiName);
}
return await getApiDefinition(sourceUrl);
};
}

Loading…
Cancel
Save