Upgrade to .net 5/6
Storefront v11 - Support for .net 5/6 and Optimizely CMS 12 & Commerce 14
Also known as Episerver CMS 12 and Episerver Commerce 14
In the new major release of Avensia Storefront v11 we have introduced support for .net 5 & 6 (.net core).
.Net framework
If you are running on .Net framework the upgrade should just work but in some cases you might need to reference nestandard in your web.config
, like this
<configuration>
<system.web>
<compilation defaultLanguage="c#">
<assemblies>
...
<add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
...
</assemblies>
</compilation>
</system.web>
</configuration>
.Net 5 & 6
Start by uninstalling all nuget references to Avensia.Storefront you currently have in your project. After this continue with upgrading your project to .Net 5 or .Net 6 and upgrade Optimizely/Episerver to CMS 12.X and Commerce 14.X. Next you need to install two packages, Avensia.Storefront.Connector.Opti and Avensia.Storefront.Connector.D365v10CU47 (Connector and Connect.Common will also be installed) of version 11.x.z.
Startup.cs
In the bottom of your Startup.cs
-> ConfigureServices
add the following:
public void ConfigureServices(IServiceCollection services)
{
...
services.AddAvensiaStorefront(new Bootstrapper());
...
}
Appsettings.json
In your new appsettings.json
you need to add your Avensia Storefront configuration, here is an example of it
{
...
"storefront": {
"module": [
{
"name": "Catalog",
"group": "ax",
"channels": [
{
"storeId": "068",
"languages": [
{
"name": "en-US"
}
]
}
]
},
{
"name": "Staging",
"group": "ax",
"channels": [
{
"storeId": "068",
"languages": [
{
"name": "en-US"
}
]
}
]
}
],
"fileSystemMediaDownloader": [
{
"name": "AxDownloader",
"mediaPath": "C:\\Contoso",
"storeId": "068"
}
],
"httpMediaDownloader": [
{
"name": "AxDownloader",
"baseUrl": "https://[YourRetUrl].axcloud.dynamics.com/MediaServer",
"storeId": "068"
}
],
"loggers": [
{
"name": "profilingReport",
"filePath": "App_Data\\StorefrontReportLog.log",
"level": "info",
"rollingMode": "date"
},
{
"name": "progress",
"filePath": "App_Data\\StorefrontProgressLog.log",
"level": "info",
"rollingMode": "date"
}
],
"fileSystemStorage": {
"temporaryFilePath": "C:\\temp\\media"
},
"pipelineSettings": {
"pagingSize": "100"
},
"databaseStaging": {
"connectionString": "[YourConnectionString]",
"readingChunkSize": "100",
"commandTimeout": "100",
"stagingWritingChunkSize": "1000",
"connectionStringName": ""
},
"retailServer": {
"retailServerUri": "https://[YourRetUrl].axcloud.dynamics.com/Commerce",
"authority": "https://sts.windows.net/[YourAuthorityGuid]/",
"clientId": "[YourClientId]",
"clientSecret": "[YourClientSecret]",
"productListingPageSize": "1000",
"categoriesPageSize": "1000",
"deletedListingsPageSize": "1000"
},
"cloudStorage": {
"connectionString": "",
"containerName": ""
}
}
...
}
IOC registration
If you have any custom pipeline steps (readers/validators/transformers/patchers/writers/reporters) or anything else that is registered in the Storefront container(s) you need to change the constructors for these to use ServiceLocator pattern instead of ctor injecton for Episerver/Optimizely dependencies. The reason for this is that Optimizely dependencies are registered in the "main"/Microsoft dependency injection container where as Avensia Storefront continues to use StructureMap as its own container.
Example, .Net Framework
public class PriceDeletionWriter<TPriceDeletionDto> : IWriter<TPriceDeletionDto, PriceToDelete>
where TPriceDeletionDto : IPriceDeletetionDto
{
private readonly IPriceDetailService _priceDetailService;
private readonly IPipelineSettings _pipelineSettings;
public PriceDeletionWriter(IPriceDetailService priceDetailService, IPipelineSettings pipelineSettings)
{
_priceDetailService = priceDetailService;
_pipelineSettings = pipelineSettings;
}
}
.Net 5/6
public class PriceDeletionWriter<TPriceDeletionDto> : IWriter<TPriceDeletionDto, PriceToDelete>
where TPriceDeletionDto : IPriceDeletetionDto
{
private readonly IPriceDetailService _priceDetailService;
private readonly IPipelineSettings _pipelineSettings;
public PriceDeletionWriter(IPipelineSettings pipelineSettings)
{
_priceDetailService = ServiceLocator.Current.GetInstance<IPriceDetailService>();
_pipelineSettings = pipelineSettings;;
}
}