Skip to content

Commit 4ac5e97

Browse files
authored
Upgrade dotnet version to net6 for version controller (#21948)
* upgrade dotnet version for version controller * upgrade to dotnet6 * Update build-steps.yml * Update analyze-steps.yml * Update build-steps.yml * Update tools/Tools.Common.Test/Tools.Common.Test.csproj
1 parent 454ddc7 commit 4ac5e97

File tree

12 files changed

+40
-56
lines changed

12 files changed

+40
-56
lines changed

.azure-pipelines/util/analyze-steps.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ steps:
2424
pwsh: true
2525

2626
- task: UseDotNet@2
27-
displayName: 'Use .NET Core sdk'
27+
displayName: 'Use .NET Core sdk 6.0.x'
2828
inputs:
2929
packageType: sdk
30-
version: 3.1.x
30+
version: 6.0.x
3131

3232
- pwsh: 'Install-Module "platyPS", "PSScriptAnalyzer" -Force -Confirm:$false -Scope CurrentUser'
3333
displayName: 'Install PowerShell Dependencies'
@@ -64,4 +64,4 @@ steps:
6464

6565
- template: publish-artifacts-steps.yml
6666
parameters:
67-
artifactName: analyze-${{ parameters.testFramework }}
67+
artifactName: analyze-${{ parameters.testFramework }}

.azure-pipelines/util/build-steps.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,11 @@ steps:
2323
displayName: 'Check Ignored File'
2424
inputs:
2525
filePath: tools/CheckIgnoredFile.ps1
26-
27-
- task: UseDotNet@2
28-
displayName: 'Use .NET Core sdk 3.1.x'
29-
inputs:
30-
packageType: sdk
31-
version: 3.1.x
32-
3326
- task: UseDotNet@2
3427
displayName: 'Use .NET Core sdk 6.0.x'
3528
inputs:
3629
packageType: sdk
3730
version: 6.0.x
38-
39-
- task: PowerShell@2
40-
displayName: Setup global.json
41-
inputs:
42-
targetType: inline
43-
script: "$SdkVersion=(dotnet --list-sdks | Select-String '[3,4,5].\\d.\\d{3}').Matches[0].Value; dotnet new globaljson --sdk-version $SdkVersion --force"
44-
pwsh: true
4531

4632
- task: DotNetCoreCLI@2
4733
displayName: Build
@@ -58,7 +44,7 @@ steps:
5844
condition: eq(variables.BuildAzPredictor, 'true')
5945
inputs:
6046
targetType: inline
61-
script: "$SdkVersion=(dotnet --list-sdks | Select-String '6.0.\\d{3}').Matches[0].Value; dotnet new globaljson --sdk-version $SdkVersion --force;dotnet msbuild tools/Az.Tools.Predictor/build.proj /t:\"clean;build;test\""
47+
script: "dotnet msbuild tools/Az.Tools.Predictor/build.proj /t:\"clean;build;test\""
6248
pwsh: true
6349
continueOnError: true
6450

tools/StaticAnalysis/BreakingChangeAnalyzer/BreakingChangeAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void Analyze(
156156

157157
var newModuleMetadata = MetadataLoader.GetModuleMetadata(moduleName);
158158
var fileName = $"{moduleName}.json";
159-
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
159+
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
160160

161161
var filePath = Path.Combine(executingPath, "SerializedCmdlets", fileName);
162162

tools/StaticAnalysis/BreakingChangeAttributesAnalyzer/CmdletBreakingChangeAttributeLoader.cs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,35 +58,28 @@ public BreakingChangeAttributesInModule GetModuleBreakingChangeAttributes(string
5858
{
5959
var results = new List<BreakingChangeAttributesInCmdlet>();
6060

61-
try
61+
var assembly = Assembly.LoadFrom(assemblyPath);
62+
foreach (var type in assembly.GetCmdletTypes())
6263
{
63-
var assembly = Assembly.LoadFrom(assemblyPath);
64-
foreach (var type in assembly.GetCmdletTypes())
65-
{
66-
var cmdlet = type.GetAttribute<CmdletAttribute>();
67-
// TODO: Remove IfDef code
64+
var cmdlet = type.GetAttribute<CmdletAttribute>();
65+
// TODO: Remove IfDef code
6866
#if !NETSTANDARD
6967
var attributes = type.GetAttributes<GenericBreakingChangeAttribute>();
7068

7169
if (attributes != null && (attributes.Count() > 0)) { }
7270
#endif
73-
var cmdletMetadata = new BreakingChangeAttributesInCmdlet
74-
{
75-
CmdletType = type,
76-
CmdletName = cmdlet.VerbName + "-" + cmdlet.NounName,
77-
// TODO: Remove IfDef code
71+
var cmdletMetadata = new BreakingChangeAttributesInCmdlet
72+
{
73+
CmdletType = type,
74+
CmdletName = cmdlet.VerbName + "-" + cmdlet.NounName,
75+
// TODO: Remove IfDef code
7876
#if !NETSTANDARD
7977
BreakingChangeAttributes = attributes.ToList()
8078
#endif
81-
};
79+
};
8280

83-
results.Add(cmdletMetadata);
84-
}
85-
}
86-
catch (Exception ex)
87-
{
88-
throw ex;
89-
}
81+
results.Add(cmdletMetadata);
82+
}
9083

9184
if (!results.Any()) return null;
9285

tools/StaticAnalysis/CmdletDiffAnalyzer/CmdletDiffAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void Analyze(
123123
var newModuleMetadata = MetadataLoader.GetModuleMetadata(moduleName);
124124
var fileName = $"{moduleName}.json";
125125
// \artifacts\StaticAnalysis
126-
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
126+
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
127127
var filePath = Path.Combine(executingPath, "SerializedCmdlets", fileName);
128128

129129
if (!File.Exists(filePath))

tools/StaticAnalysis/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public static void Main(string[] args)
169169
}
170170

171171
// https://stackoverflow.com/a/9737418/294804
172-
var assemblyDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
172+
var assemblyDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).LocalPath);
173173
ExceptionsDirectory = Path.Combine(assemblyDirectory, "Exceptions");
174174
bool useExceptions = !args.Any(a => a.Equals("--dont-use-exceptions") || a.Equals("-d"));
175175
var useNetcore = args.Any(a => a.Equals("--use-netcore") || a.Equals("-u"));

tools/StaticAnalysis/StaticAnalysis.Netcore.csproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<Import Project="$(MSBuildThisFileDirectory)..\..\Repo.props" />
44

55
<PropertyGroup>
66
<OutputType>Exe</OutputType>
7-
<TargetFramework>netcoreapp3.1</TargetFramework>
7+
<TargetFramework>net6.0</TargetFramework>
88
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
99
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1010
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -30,14 +30,6 @@
3030
<ProjectReference Include="..\Tools.Common\Tools.Common.Netcore.csproj" />
3131
</ItemGroup>
3232

33-
<ItemGroup>
34-
<Compile Update="Properties\Resources.Designer.cs">
35-
<DesignTime>True</DesignTime>
36-
<AutoGen>True</AutoGen>
37-
<DependentUpon>Resources.resx</DependentUpon>
38-
</Compile>
39-
</ItemGroup>
40-
4133
<ItemGroup>
4234
<EmbeddedResource Update="Properties\Resources.resx">
4335
<Generator>ResXFileCodeGenerator</Generator>
@@ -59,4 +51,12 @@
5951
<HintPath>lib\Markdown.MAML.dll</HintPath>
6052
</Reference>
6153
</ItemGroup>
54+
55+
<ItemGroup>
56+
<Compile Update="Properties\Resources.Designer.cs">
57+
<DesignTime>True</DesignTime>
58+
<AutoGen>True</AutoGen>
59+
<DependentUpon>Resources.resx</DependentUpon>
60+
</Compile>
61+
</ItemGroup>
6262
</Project>

tools/StaticAnalysis/UXMetadataAnalyzer/UXMetadataAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public UXMetadataAnalyzer()
5555
{
5656
Name = "UX Metadata Analyzer";
5757
UXMetadataIssueReportLoggerName = "UXMetadataIssues.csv";
58-
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
58+
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
5959
var schemaPath = Path.Combine(executingPath, "UXMetadataAnalyzer", "PortalInputSchema.json");
6060
var schemaContent = File.ReadAllText(schemaPath);
6161
schema = JsonSchema.FromJsonAsync(schemaContent).Result;

tools/Tools.Common.Test/Tools.Common.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="$(MSBuildThisFileDirectory)..\Common.Netcore.Dependencies.Test.targets" />
44

55
<PropertyGroup>
6-
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
<TargetFramework>net6.0</TargetFramework>
77
<IsPackable>false</IsPackable>
88
</PropertyGroup>
99

tools/Tools.Common/Loaders/AssemblyLoader.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,17 @@ public AssemblyMetadata GetReflectedAssemblyInfo(string assemblyName)
4545
AssemblyMetadata result = null;
4646
try
4747
{
48-
result = new AssemblyMetadata(Assembly.ReflectionOnlyLoad(assemblyName));
48+
var resolver = new PathAssemblyResolver(new string[] { assemblyName, typeof(object).Assembly.Location });
49+
using (var mlc = new MetadataLoadContext(resolver))
50+
{
51+
// Load assembly into MetadataLoadContext.
52+
Assembly assembly = mlc.LoadFromAssemblyPath(assemblyName);
53+
result = new AssemblyMetadata(assembly);
54+
}
4955
}
5056
catch
5157
{
5258
}
53-
5459
return result;
5560
}
5661

0 commit comments

Comments
 (0)