Skip to content

Commit

Permalink
Multitool: Enable cross-platform "dotnet tool" support (#1474)
Browse files Browse the repository at this point in the history
* Enable cross-platform dotnet tool support for multitool

* Fix inconsistent trailing newline in DotnetToolSettings

* Update appveyor .net core version to current LTS to support netcoreapp2.1 target

* Use SDK version instead of runtime version for appveyor .net core config

* Update test projects to build and run in netcoreapp2.1

* Workaround for appveyor #1915

* update command name to just sarif per PR feedback
  • Loading branch information
dbjorge authored and michaelcfanning committed May 7, 2019
1 parent 3c9f2df commit 6ba091a
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 29 deletions.
4 changes: 1 addition & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ branches:
- tc-31
- sarif-v1

platform: Any CPU

install:
- ps: .\dotnet-install.ps1 --version 2.0.0
- ps: .\dotnet-install.ps1 --version 2.1.506

configuration:
- Release
Expand Down
2 changes: 1 addition & 1 deletion scripts/Projects.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $Frameworks.NetFx = @("net461")
$Frameworks.Library = @("netstandard2.0") + $Frameworks.NetFx

# Frameworks for which we build applications.
$Frameworks.Application = @("netcoreapp2.0") + $Frameworks.NetFx
$Frameworks.Application = @("netcoreapp2.0", "netcoreapp2.1") + $Frameworks.NetFx

$Frameworks.All = ($Frameworks.Library + $Frameworks.Application | Select -Unique)

Expand Down
16 changes: 2 additions & 14 deletions scripts/Run-Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,15 @@ Import-Module -Force $PSScriptRoot\Projects.psm1

$ScriptName = $([io.Path]::GetFileNameWithoutExtension($PSCommandPath))

$ReporterOption = $null
if ($AppVeyor) {
$ReporterOption = "-appveyor"
}

$TestRunnerRootPath = "$NuGetPackageRoot\xunit.runner.console\2.3.1\tools\"

$failedTestProjects = @()
foreach ($project in $Projects.Tests) {
foreach ($framework in $Frameworks.Application) {

if (-not $AppVeyor -and $framework -ne "netcoreapp2.0") { continue; }

Write-Information "Running tests in ${project}: $framework..."
Push-Location $BinRoot\${Platform}_$Configuration\$project\$framework
$dll = "$project" + ".dll"
if ($framework -eq "netcoreapp2.0") {
& dotnet ${TestRunnerRootPath}netcoreapp2.0\xunit.console.dll $dll $ReporterOption
} else {
& ${TestRunnerRootPath}net452\xunit.console.exe $dll $ReporterOption
}
Push-Location $SourceRoot\$project
& dotnet test --no-build --framework $framework --configuration $Configuration
if ($LASTEXITCODE -ne 0) {
$failedTestProjects += "${project}: $framework"
}
Expand Down
25 changes: 21 additions & 4 deletions src/Nuget/Sarif.Multitool.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,47 @@
<projectUrl>https://github.com/microsoft/sarif-sdk</projectUrl>
<iconUrl>https://go.microsoft.com/fwlink/?linkid=2008860</iconUrl>
<tags>SARIF command line static analysis</tags>
<packageTypes>
<packageType name="DotnetTool" />
</packageTypes>
</metadata>
<files>
<!-- The subfolder layout for the different TargetFrameworks is intentionally inconsistent -->
<!-- net461 and netcoreapp2.0 pack to tools\TargetFramework\* for backcompat -->
<file src="bld\bin\$platform$_$configuration$\Sarif.Multitool\Publish\net461\Sarif.Multitool.exe.config"
target="tools\net461"
/>

<file src="bld\bin\$platform$_$configuration$\Sarif.Multitool\Publish\net461\**"
target="tools\net461"
exclude="bld\bin\$platform$_$configuration$\Sarif.Multitool\Publish\net461\Sarif*"
/>
<file src="bld\bin\Signing\net461\**"
target="tools\net461"
/>

<file src="bld\bin\$platform$_$configuration$\Sarif.Multitool\Publish\netcoreapp2.0\**"
target="tools\netcoreapp2.0"
exclude="bld\bin\$platform$_$configuration$\Sarif.Multitool\Publish\netcoreapp2.0\Sarif*.dll"
/>
<file src="bld\bin\Signing\net461\**"
target="tools\net461"
/>
<file src="bld\bin\Signing\netcoreapp2.0\**"
target="tools\netcoreapp2.0"
/>
<file src="bld\bin\Signing\netstandard2.0\**"
target="tools\netcoreapp2.0"
/>

<!-- netcoreapp2.1 packs to tools\TargetFramework\any\* for compatibility with dotnet tool install -->
<file src="bld\bin\$platform$_$configuration$\Sarif.Multitool\Publish\netcoreapp2.1\**"
target="tools\netcoreapp2.1\any"
exclude="bld\bin\$platform$_$configuration$\Sarif.Multitool\Publish\netcoreapp2.1\Sarif*.dll"
/>
<file src="bld\bin\Signing\netcoreapp2.1\**"
target="tools\netcoreapp2.1\any"
/>
<file src="bld\bin\Signing\netstandard2.0\**"
target="tools\netcoreapp2.1\any"
/>

<file src="src\ReleaseHistory.md" />
<file src="src\Sarif.Multitool\**\*.cs" target="src" />
</files>
Expand Down
6 changes: 6 additions & 0 deletions src/Sarif.Multitool/DotnetToolSettings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<DotNetCliTool Version="1">
<Commands>
<Command Name="sarif" EntryPoint="Sarif.Multitool.dll" Runner="dotnet" />
</Commands>
</DotNetCliTool>
10 changes: 8 additions & 2 deletions src/Sarif.Multitool/Sarif.Multitool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1</TargetFrameworks>
<LangVersion>7.3</LangVersion>
</PropertyGroup>

<!-- PackAsTool is supported/recommended for .NET Core >= 2.1 -->
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackAsTool>true</PackAsTool>
</PropertyGroup>

<PropertyGroup Label="AssemblyAttributes">
<AssemblyTitle>SARIF Multitool</AssemblyTitle>
<Description>Command line tool to perform transformations of input files to SARIF.</Description>
Expand All @@ -14,7 +19,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.props))\build.props" />

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.2.1" />
<PackageReference Include="CommandLineParser" Version="2.5.0" />
<PackageReference Include="Microsoft.Json.Pointer" Version="0.64.0" />
<PackageReference Include="Microsoft.Json.Schema" Version="0.64.0" />
<PackageReference Include="Microsoft.Json.Schema.Validation" Version="0.64.0" />
Expand Down Expand Up @@ -52,6 +57,7 @@

<ItemGroup>
<EmbeddedResource Include="$(SolutionDir)\Sarif\Schemata\sarif-schema.json" CopyToOutputDirectory="PreserveNewest" />
<EmbeddedResource Include=".\DotnetToolSettings.xml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>7.3</LangVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>7.3</LangVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>7.3</LangVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>7.3</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/Test.UnitTests.Sarif/Test.UnitTests.Sarif.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>7.3</LangVersion>
Expand Down

0 comments on commit 6ba091a

Please sign in to comment.