Hi,
I am upgrading my API Service Application from .Net 8.0 to .Net 10.0. Below is how the code looks like--
- There is a Powershell script which deploys the application and below piece of code executes within this script where the error arises (hiding dll name with ** for security concerns).
$scriptBlock = { param ($path, $assemblyPath) function GenerateSecurityMap { param () Add-Type -Path $assemblyPath $map = [**.**.Wcf.SecurityMapProvider]::GetSecurityMap() $jsonContent = $map | ConvertTo-Json -Depth 20 $jsonContent | Set-Content -Path $path } GenerateSecurityMap } $pwshOutput = & pwsh -Command $scriptBlock -Args $jsonPath, $CaiWcfAssemblyPath *>&1 | Tee-Object -Variable realtimeOutput
When the above script get executed in Octopus Deploy, I get the error "Unable to find type "..Wcf.SecurityMapProvider"". This particular assembly gets generated runtime(dynamically) within another assembly (..TestHarness.SecurityMapGenerator) which is based on .netstandard 2.0 like below-->
var sourceCode = $@" using System.Collections.Generic; using System.Text.Json; namespace **.**.Wcf {{ public static class SecurityMapProvider {{ public static Dictionary<string, Dictionary<string, string>> GetSecurityMap() => JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(@""{jsonContent.Replace("\"", "\"\"")}""); }} }}"; context.AddSource("SecurityMapProvider.g.cs", sourceCode); //context.AddSource("SecurityMapProvider.g.cs", SourceText.From(jsonContent, Encoding.UTF8));
..TestHarness.SecurityMapGenerator project file code-->
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netstandard2.0</TargetFramework> <LangVersion>latest</LangVersion> <EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules> <IsRoslynComponent>true</IsRoslynComponent> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.CodeAnalysis.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> <PackageReference Include="Microsoft.CodeAnalysis.CSharp" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" /> <PackageReference Include="Newtonsoft.Json" PrivateAssets="all"/> </ItemGroup> </Project>
Below are the version of references included in above project--
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.3.0-2.final" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.14.0" />
- Note that the pwsh (powershell) edition in Octopus Deploy is "Windows Powershell(Desktop)"
- All the above code works fine with .Net 8.0 but fails after upgrading to .Net 10.0
The question is more about .NET upgrade and less about AWS. Is this happening for a specific AWS service?
Hi @Shajam. Thanks for the reply. It happens within Codebuild. The Powershell runs within the codebuild hence I posted in this forum. If it sounds irrelevant in this forum I am happy to close it. Thanks