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
This commit is contained in:
Beisi Zhou 2023-06-02 17:11:24 +08:00 коммит произвёл GitHub
Родитель 454ddc7fba
Коммит 4ac5e97579
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 40 добавлений и 56 удалений

Просмотреть файл

@ -24,10 +24,10 @@ steps:
pwsh: true
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
displayName: 'Use .NET Core sdk 6.0.x'
inputs:
packageType: sdk
version: 3.1.x
version: 6.0.x
- pwsh: 'Install-Module "platyPS", "PSScriptAnalyzer" -Force -Confirm:$false -Scope CurrentUser'
displayName: 'Install PowerShell Dependencies'
@ -64,4 +64,4 @@ steps:
- template: publish-artifacts-steps.yml
parameters:
artifactName: analyze-${{ parameters.testFramework }}
artifactName: analyze-${{ parameters.testFramework }}

Просмотреть файл

@ -23,25 +23,11 @@ steps:
displayName: 'Check Ignored File'
inputs:
filePath: tools/CheckIgnoredFile.ps1
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 3.1.x'
inputs:
packageType: sdk
version: 3.1.x
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 6.0.x'
inputs:
packageType: sdk
version: 6.0.x
- task: PowerShell@2
displayName: Setup global.json
inputs:
targetType: inline
script: "$SdkVersion=(dotnet --list-sdks | Select-String '[3,4,5].\\d.\\d{3}').Matches[0].Value; dotnet new globaljson --sdk-version $SdkVersion --force"
pwsh: true
- task: DotNetCoreCLI@2
displayName: Build
@ -58,7 +44,7 @@ steps:
condition: eq(variables.BuildAzPredictor, 'true')
inputs:
targetType: inline
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\""
script: "dotnet msbuild tools/Az.Tools.Predictor/build.proj /t:\"clean;build;test\""
pwsh: true
continueOnError: true

Просмотреть файл

@ -156,7 +156,7 @@ namespace StaticAnalysis.BreakingChangeAnalyzer
var newModuleMetadata = MetadataLoader.GetModuleMetadata(moduleName);
var fileName = $"{moduleName}.json";
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
var filePath = Path.Combine(executingPath, "SerializedCmdlets", fileName);

Просмотреть файл

@ -58,35 +58,28 @@ namespace StaticAnalysis.BreakingChangeAttributesAnalyzer
{
var results = new List<BreakingChangeAttributesInCmdlet>();
try
var assembly = Assembly.LoadFrom(assemblyPath);
foreach (var type in assembly.GetCmdletTypes())
{
var assembly = Assembly.LoadFrom(assemblyPath);
foreach (var type in assembly.GetCmdletTypes())
{
var cmdlet = type.GetAttribute<CmdletAttribute>();
// TODO: Remove IfDef code
var cmdlet = type.GetAttribute<CmdletAttribute>();
// TODO: Remove IfDef code
#if !NETSTANDARD
var attributes = type.GetAttributes<GenericBreakingChangeAttribute>();
if (attributes != null && (attributes.Count() > 0)) { }
#endif
var cmdletMetadata = new BreakingChangeAttributesInCmdlet
{
CmdletType = type,
CmdletName = cmdlet.VerbName + "-" + cmdlet.NounName,
// TODO: Remove IfDef code
var cmdletMetadata = new BreakingChangeAttributesInCmdlet
{
CmdletType = type,
CmdletName = cmdlet.VerbName + "-" + cmdlet.NounName,
// TODO: Remove IfDef code
#if !NETSTANDARD
BreakingChangeAttributes = attributes.ToList()
#endif
};
};
results.Add(cmdletMetadata);
}
}
catch (Exception ex)
{
throw ex;
}
results.Add(cmdletMetadata);
}
if (!results.Any()) return null;

Просмотреть файл

@ -123,7 +123,7 @@ namespace StaticAnalysis.CmdletDiffAnalyzer
var newModuleMetadata = MetadataLoader.GetModuleMetadata(moduleName);
var fileName = $"{moduleName}.json";
// \artifacts\StaticAnalysis
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
var filePath = Path.Combine(executingPath, "SerializedCmdlets", fileName);
if (!File.Exists(filePath))

Просмотреть файл

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

Просмотреть файл

@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(MSBuildThisFileDirectory)..\..\Repo.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@ -30,14 +30,6 @@
<ProjectReference Include="..\Tools.Common\Tools.Common.Netcore.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
@ -59,4 +51,12 @@
<HintPath>lib\Markdown.MAML.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
</Project>

Просмотреть файл

@ -55,7 +55,7 @@ namespace StaticAnalysis.UXMetadataAnalyzer
{
Name = "UX Metadata Analyzer";
UXMetadataIssueReportLoggerName = "UXMetadataIssues.csv";
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
var schemaPath = Path.Combine(executingPath, "UXMetadataAnalyzer", "PortalInputSchema.json");
var schemaContent = File.ReadAllText(schemaPath);
schema = JsonSchema.FromJsonAsync(schemaContent).Result;

Просмотреть файл

@ -3,7 +3,7 @@
<Import Project="$(MSBuildThisFileDirectory)..\Common.Netcore.Dependencies.Test.targets" />
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Просмотреть файл

@ -45,12 +45,17 @@ namespace Tools.Common.Loaders
AssemblyMetadata result = null;
try
{
result = new AssemblyMetadata(Assembly.ReflectionOnlyLoad(assemblyName));
var resolver = new PathAssemblyResolver(new string[] { assemblyName, typeof(object).Assembly.Location });
using (var mlc = new MetadataLoadContext(resolver))
{
// Load assembly into MetadataLoadContext.
Assembly assembly = mlc.LoadFromAssemblyPath(assemblyName);
result = new AssemblyMetadata(assembly);
}
}
catch
{
}
return result;
}

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>Tools.Common</AssemblyName>
<RootNamespace>Tools.Common</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

Просмотреть файл

@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>