Skip to content

Commit 907063b

Browse files
committed
Merged the two CLI projects. (v0.0.5)
1 parent 26a0a64 commit 907063b

13 files changed

+81
-145
lines changed

CompatibilityChecker.sln

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28307.271
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29519.181
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C355D891-5C1D-4794-9981-9077586D4D39}"
77
ProjectSection(SolutionItems) = preProject
@@ -14,9 +14,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompatibilityCheckerTests",
1414
EndProject
1515
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompatibilityChecker", "CompatibilityChecker\CompatibilityChecker.csproj", "{9A4BE2CE-277F-41C5-AB31-E5C6ECFD0EEB}"
1616
EndProject
17-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompatibilityCheckerCoreCLI", "CompatibilityCheckerCoreCLI\CompatibilityCheckerCoreCLI.csproj", "{F12B242C-9EC3-4ABC-BFC5-50156E4B5CB4}"
18-
EndProject
19-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompatibilityCheckerCLI", "CompatibilityCheckerCLI\CompatibilityCheckerCLI.csproj", "{A9745E2F-F26C-4071-8461-1E381E0A654C}"
17+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompatibilityCheckerCLI", "CompatibilityCheckerCLI\CompatibilityCheckerCLI.csproj", "{F12B242C-9EC3-4ABC-BFC5-50156E4B5CB4}"
2018
EndProject
2119
Global
2220
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -36,10 +34,6 @@ Global
3634
{F12B242C-9EC3-4ABC-BFC5-50156E4B5CB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
3735
{F12B242C-9EC3-4ABC-BFC5-50156E4B5CB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
3836
{F12B242C-9EC3-4ABC-BFC5-50156E4B5CB4}.Release|Any CPU.Build.0 = Release|Any CPU
39-
{A9745E2F-F26C-4071-8461-1E381E0A654C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40-
{A9745E2F-F26C-4071-8461-1E381E0A654C}.Debug|Any CPU.Build.0 = Debug|Any CPU
41-
{A9745E2F-F26C-4071-8461-1E381E0A654C}.Release|Any CPU.ActiveCfg = Release|Any CPU
42-
{A9745E2F-F26C-4071-8461-1E381E0A654C}.Release|Any CPU.Build.0 = Release|Any CPU
4337
EndGlobalSection
4438
GlobalSection(SolutionProperties) = preSolution
4539
HideSolutionNode = FALSE

CompatibilityChecker/AzurePipelinesMessageLogger.cs

+22-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,30 @@
44

55
public class AzurePipelinesMessageLogger : IMessageLogger
66
{
7+
Severity? maxSeverity;
8+
9+
public AzurePipelinesMessageLogger(Severity? MaxSeverity)
10+
{
11+
maxSeverity = MaxSeverity;
12+
}
13+
14+
public AzurePipelinesMessageLogger()
15+
{
16+
maxSeverity = null;
17+
}
18+
719
public virtual void Report(Message message)
820
{
9-
switch (message.Severity)
21+
Severity sev;
22+
if (maxSeverity.HasValue)
23+
{
24+
sev = message.Severity > maxSeverity.Value ? maxSeverity.Value : message.Severity;
25+
}
26+
else
27+
{
28+
sev = message.Severity;
29+
}
30+
switch (sev)
1031
{
1132
case Severity.Error:
1233
Console.Error.WriteLine("##vso[task.logissue type=error]{0}", message);
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net47;netcoreapp2.2</TargetFrameworks>
4+
<TargetFrameworks>net48;netstandard2.1</TargetFrameworks>
5+
<Version>0.0.5</Version>
56
</PropertyGroup>
67

78
<ItemGroup>
89
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
910
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
1011
</ItemGroup>
1112

12-
<ItemGroup>
13+
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
1314
<Reference Include="Microsoft.CSharp" />
1415
</ItemGroup>
1516

17+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
18+
<PackageReference Include="Microsoft.CSharp" Version="4.7.0"/>
19+
</ItemGroup>
20+
1621
</Project>

CompatibilityChecker/Severity.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
namespace CompatibilityChecker
22
{
3-
internal enum Severity
3+
public enum Severity
44
{
5-
Disabled,
6-
Information,
7-
Warning,
8-
Error,
5+
Disabled = 0,
6+
Information = 1,
7+
Warning = 2,
8+
Error = 3,
99
}
1010
}

CompatibilityCheckerCLI/App.config

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,28 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
43
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{A9745E2F-F26C-4071-8461-1E381E0A654C}</ProjectGuid>
84
<OutputType>Exe</OutputType>
9-
<RootNamespace>CompatibilityCheckerCLI</RootNamespace>
10-
<AssemblyName>CompatibilityCheckerCLI</AssemblyName>
11-
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
12-
<FileAlignment>512</FileAlignment>
13-
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14-
<Deterministic>true</Deterministic>
5+
<TargetFrameworks>netcoreapp3.1;net48</TargetFrameworks>
6+
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
7+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
8+
<ApplicationIcon />
9+
<StartupObject />
10+
<LangVersion>latest</LangVersion>
11+
<Version>0.0.5</Version>
1512
</PropertyGroup>
16-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17-
<PlatformTarget>AnyCPU</PlatformTarget>
13+
14+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
15+
<DebugType>portable</DebugType>
1816
<DebugSymbols>true</DebugSymbols>
19-
<DebugType>full</DebugType>
20-
<Optimize>false</Optimize>
21-
<OutputPath>bin\Debug\</OutputPath>
22-
<DefineConstants>DEBUG;TRACE</DefineConstants>
23-
<ErrorReport>prompt</ErrorReport>
24-
<WarningLevel>4</WarningLevel>
2517
</PropertyGroup>
26-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27-
<PlatformTarget>AnyCPU</PlatformTarget>
28-
<DebugType>pdbonly</DebugType>
29-
<Optimize>true</Optimize>
30-
<OutputPath>bin\Release\</OutputPath>
31-
<DefineConstants>TRACE</DefineConstants>
32-
<ErrorReport>prompt</ErrorReport>
33-
<WarningLevel>4</WarningLevel>
34-
</PropertyGroup>
35-
<ItemGroup>
36-
<Reference Include="System" />
37-
<Reference Include="System.Core" />
38-
<Reference Include="Microsoft.CSharp" />
39-
<Reference Include="System.Data" />
40-
</ItemGroup>
41-
<ItemGroup>
42-
<Compile Include="..\CompatibilityCheckerCoreCLI\Program.cs" />
43-
<Compile Include="Properties\AssemblyInfo.cs" />
44-
</ItemGroup>
45-
<ItemGroup>
46-
<None Include="App.config" />
47-
</ItemGroup>
18+
4819
<ItemGroup>
49-
<ProjectReference Include="..\CompatibilityChecker\CompatibilityChecker.csproj">
50-
<Project>{9a4be2ce-277f-41c5-ab31-e5c6ecfd0eeb}</Project>
51-
<Name>CompatibilityChecker</Name>
52-
</ProjectReference>
20+
<PackageReference Include="CommandLineParser" Version="2.5.0" />
21+
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
5322
</ItemGroup>
23+
5424
<ItemGroup>
55-
<PackageReference Include="CommandLineParser">
56-
<Version>2.5.0</Version>
57-
</PackageReference>
58-
<PackageReference Include="System.Reflection.Metadata">
59-
<Version>1.6.0</Version>
60-
</PackageReference>
25+
<ProjectReference Include="..\CompatibilityChecker\CompatibilityChecker.csproj" />
6126
</ItemGroup>
62-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
63-
</Project>
27+
28+
</Project>

CompatibilityCheckerCoreCLI/Program.cs CompatibilityCheckerCLI/Program.cs

+20-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public class Options
2424
[Option('a', "azure-pipelines", Required = false, Default = false, HelpText = "Include the logging prefixes for Azure Pipelines.")]
2525
public bool AzurePipelines { get; set; }
2626

27+
[Option('w', "warnings-only", Required = false, Default = false, HelpText = "Do not raise errors for Azure Pipelines, it also swallows the return code.")]
28+
public bool WarningsOnly { get; set; }
29+
2730
[Usage()]
2831
public static IEnumerable<Example> Examples {
2932
get {
@@ -65,7 +68,21 @@ private static void RunWithOptions(Options opts)
6568
{
6669
using (PEReader newAssembly = new PEReader(File.OpenRead(newFile.FullName)))
6770
{
68-
IMessageLogger logger = opts.AzurePipelines ? (IMessageLogger)new AzurePipelinesMessageLogger() : new ConsoleMessageLogger();
71+
IMessageLogger logger;
72+
if (opts.AzurePipelines)
73+
{
74+
if (opts.WarningsOnly)
75+
{
76+
logger = new AzurePipelinesMessageLogger(Severity.Warning);
77+
}
78+
else
79+
{
80+
logger = new AzurePipelinesMessageLogger();
81+
}
82+
} else
83+
{
84+
logger = new ConsoleMessageLogger();
85+
}
6986
Analyzer analyzer = new Analyzer(referenceAssembly, newAssembly, null, logger);
7087
analyzer.Run();
7188
if (analyzer.HasRun)
@@ -76,7 +93,7 @@ private static void RunWithOptions(Options opts)
7693
{
7794
if(opts.AzurePipelines)
7895
Console.WriteLine("##vso[task.complete result=SucceededWithIssues]");
79-
Environment.ExitCode = -2;
96+
Environment.ExitCode = opts.WarningsOnly ? 0 : -2;
8097
return;
8198
}
8299
else
@@ -90,7 +107,7 @@ private static void RunWithOptions(Options opts)
90107
{
91108
if (opts.AzurePipelines)
92109
Console.WriteLine("##vso[task.complete result=Failed]");
93-
Environment.ExitCode = -1;
110+
Environment.ExitCode = opts.WarningsOnly ? 0 : -1;
94111
return;
95112
}
96113
}

CompatibilityCheckerCLI/Properties/AssemblyInfo.cs

-36
This file was deleted.

CompatibilityCheckerCoreCLI/Properties/launchSettings.json CompatibilityCheckerCLI/Properties/launchSettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"CompatibilityCheckerCoreExample": {
44
"commandName": "Project",
5-
"commandLineArgs": "\"..\\..\\..\\..\\MediaBrowser.Common_nuget.dll\" \"..\\..\\..\\..\\MediaBrowser.Common_artifact.dll\" --azure-pipelines"
5+
"commandLineArgs": "\"..\\..\\..\\..\\MediaBrowser.Common_nuget.dll\" \"..\\..\\..\\..\\MediaBrowser.Common_artifact.dll\" --azure-pipelines --warnings-only"
66
}
77
}
88
}

CompatibilityCheckerCoreCLI/CompatibilityCheckerCoreCLI.csproj

-27
This file was deleted.

CompatibilityCheckerTests/CompatibilityCheckerTests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<AppDesignerFolder>Properties</AppDesignerFolder>
99
<RootNamespace>CompatibilityCheckerTests</RootNamespace>
1010
<AssemblyName>CompatibilityCheckerTests</AssemblyName>
11-
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
11+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
1212
<FileAlignment>512</FileAlignment>
1313
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1414
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

build-for-ci.bat

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@ECHO OFF
2+
3+
dotnet publish -c Release --framework netcoreapp3.1 --self-contained false -r linux-x64 CompatibilityCheckerCLI\CompatibilityCheckerCLI.csproj

0 commit comments

Comments
 (0)