Skip to content

Commit ce3ed09

Browse files
author
Alexandre Rocha Lima e Marcondes
committed
New structure borrowed from https://github.com/AArnott/pinvoke
1 parent 1900bbb commit ce3ed09

File tree

85 files changed

+794
-80
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+794
-80
lines changed

build.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@PowerShell.exe -ExecutionPolicy RemoteSigned "%~dpn0.ps1" %*

build.ps1

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<#
2+
.Synopsis
3+
Acquires dependencies, builds, and tests this project.
4+
.Description
5+
If no actions are specified, the default is to run all actions.
6+
.Parameter Restore
7+
Restore NuGet packages.
8+
.Parameter Build
9+
Build the entire project. Requires that -Restore is or has been executed.
10+
.Parameter Test
11+
Run all built tests.
12+
.Parameter Configuration
13+
The configuration to build. Either "debug" or "release". The default is debug.
14+
.Parameter WarnAsError
15+
Converts all build warnings to errors. Useful in preparation to sending a pull request.
16+
#>
17+
[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Medium')]
18+
Param(
19+
[switch]$Restore,
20+
[switch]$Build,
21+
[switch]$Test,
22+
[Parameter()][ValidateSet('debug', 'release')]
23+
[string]$Configuration = 'debug',
24+
[switch]$WarnAsError = $true
25+
)
26+
27+
$NothingToDo = !($Restore -or $Build -or $Test)
28+
if ($NothingToDo) {
29+
Write-Output "No actions specified. Applying default actions."
30+
$Restore = $true
31+
$Build = $true
32+
$Test = $true
33+
}
34+
35+
# External dependencies
36+
$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/v3.3.0/nuget.exe"
37+
38+
# Path variables
39+
$ProjectRoot = Split-Path -parent $PSCommandPath
40+
$SolutionFolder = Join-Path $ProjectRoot src
41+
$SolutionFile = Join-Path $SolutionFolder "PInvoke.sln"
42+
$ToolsFolder = Join-Path $ProjectRoot tools
43+
$BinFolder = Join-Path $ProjectRoot "bin"
44+
$BinConfigFolder = Join-Path $BinFolder $Configuration
45+
$BinTestsFolder = Join-Path $BinConfigFolder "Tests"
46+
47+
# Set script scope for external tool variables.
48+
$NuGetPath = Join-Path $ToolsFolder "NuGet.exe"
49+
$NuGetCommand = Get-Command $NuGetPath -ErrorAction SilentlyContinue
50+
$MSBuildCommand = Get-Command MSBuild.exe -ErrorAction SilentlyContinue
51+
$VSTestConsoleCommand = Get-Command vstest.console.exe -ErrorAction SilentlyContinue
52+
53+
Function Get-ExternalTools {
54+
if (!$NuGetCommand) {
55+
Write-Host "NuGet.exe not found. Downloading to $NuGetPath..."
56+
if ($PSCmdlet.ShouldProcess($sourceNuGetExe, "Download")) {
57+
Invoke-WebRequest $sourceNugetExe -OutFile $NuGetPath
58+
}
59+
60+
$script:NuGetCommand = Get-Command $NuGetPath
61+
}
62+
63+
if (!$MSBuildCommand) {
64+
Write-Error "Unable to find MSBuild.exe. Make sure you're running in a VS Developer Prompt."
65+
exit 1;
66+
}
67+
68+
if (!$VSTestConsoleCommand) {
69+
Write-Error "Unable to find vstest.console.exe. Make sure you're running in a VS Developer prompt."
70+
exit 2;
71+
}
72+
}
73+
74+
Get-ExternalTools
75+
76+
if ($Restore -and $PSCmdlet.ShouldProcess($SolutionFile, "NuGet restore")) {
77+
Write-Output "Restoring NuGet packages..."
78+
& $NuGetCommand.Path restore $SolutionFile -Verbosity quiet
79+
}
80+
81+
if ($Build -and $PSCmdlet.ShouldProcess($SolutionFile, "Build")) {
82+
Write-Output "Building..."
83+
& $MSBuildCommand.Path $SolutionFile /nologo /nr:false /m /v:minimal /fl "/flp:verbosity=normal;logfile=msbuild.log" "/flp1:warningsonly;logfile=msbuild.wrn" "/flp2:errorsonly;logfile=msbuild.err"
84+
$fail = $false
85+
86+
$warnings = Get-Content msbuild.wrn
87+
$errors = Get-Content msbuild.err
88+
$WarningsPrompt = "$(($warnings | Measure-Object -Line).Lines) warnings during build"
89+
$ErrorsPrompt = "$(($errors | Measure-Object -Line).Lines) errors during build"
90+
if ($errors.length -gt 0) {
91+
Write-Error $ErrorsPrompt
92+
$fail = $true
93+
} else {
94+
Write-Output $ErrorsPrompt
95+
}
96+
97+
if ($WarnAsError -and $warnings.length -gt 0) {
98+
Write-Error $WarningsPrompt
99+
$fail = $true
100+
} elseif ($warnings.length -gt 0) {
101+
Write-Warning $WarningsPrompt
102+
} else {
103+
Write-Output $WarningsPrompt
104+
}
105+
106+
if ($fail) {
107+
exit 3;
108+
}
109+
}
110+
111+
if ($Test -and $PSCmdlet.ShouldProcess('Test assemblies', 'vstest.console.exe')) {
112+
$TestAssemblies = Get-ChildItem -Recurse "$BinTestsFolder\*.Tests.dll"
113+
Write-Output "Testing..."
114+
# Add /Parallel switch when VS2015 Update 2 is more popular, as it's new in that version.
115+
& $VSTestConsoleCommand.Path /TestAdapterPath:$BinTestsFolder $TestAssemblies
116+
}

CLR.Extensions.NuGet/CLR.Extensions.NuGet.nuproj renamed to src/CLR.Extensions.NuGet/CLR.Extensions.NuGet.nuproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " />
34
<ItemGroup Label="ProjectConfigurations">
45
<ProjectConfiguration Include="Debug|AnyCPU">
56
<Configuration>Debug</Configuration>
@@ -46,4 +47,5 @@
4647
<OutputPath>$(ProjectRoot)bin\$(Configuration)\Packages\</OutputPath>
4748
</PropertyGroup>
4849
<Import Project="$(NuProjPath)\NuProj.targets" />
50+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " />
4951
</Project>

CLR.Extensions/CLR.Extensions.csproj renamed to src/CLR.Extensions/CLR.Extensions.csproj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " />
34
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
45
<PropertyGroup>
56
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
@@ -33,6 +34,9 @@
3334
<ErrorReport>prompt</ErrorReport>
3435
<WarningLevel>4</WarningLevel>
3536
</PropertyGroup>
37+
<ItemGroup>
38+
<None Include="project.json" />
39+
</ItemGroup>
3640
<ItemGroup>
3741
<!-- A reference to the entire .NET Framework is automatically included -->
3842
<None Include="..\Extensions.licenseheader">
@@ -44,11 +48,6 @@
4448
<Compile Include="ReflectionExtensions.cs" />
4549
</ItemGroup>
4650
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
47-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
48-
Other similar extension points exist, see Microsoft.Common.targets.
49-
<Target Name="BeforeBuild">
50-
</Target>
51-
<Target Name="AfterBuild">
52-
</Target>
51+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " />
5352
-->
5453
</Project>

src/CLR.Extensions/project.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"supports": { },
3+
"dependencies": {
4+
"Nerdbank.GitVersioning": {
5+
"version": "1.4.41",
6+
"suppressParent": "none"
7+
},
8+
"Nuproj": "0.10.48-beta-gea4a31bbc5",
9+
"Nuproj.Common": {
10+
"version": "0.10.48-beta-gea4a31bbc5",
11+
"suppressParent": "none"
12+
},
13+
"StyleCop.Analyzers": "1.0.0"
14+
},
15+
"frameworks": {
16+
".NETPortable,Version=v4.5,Profile=Profile111": { }
17+
}
18+
}

Debugging.Extensions.NuGet/Debugging.Extensions.NuGet.nuproj renamed to src/Debugging.Extensions.NuGet/Debugging.Extensions.NuGet.nuproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " />
34
<ItemGroup Label="ProjectConfigurations">
45
<ProjectConfiguration Include="Debug|AnyCPU">
56
<Configuration>Debug</Configuration>
@@ -46,4 +47,5 @@
4647
<NoDefaultExcludes />
4748
</PropertyGroup>
4849
<Import Project="$(NuProjPath)\NuProj.targets" />
50+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " />
4951
</Project>

0 commit comments

Comments
 (0)