Skip to content

WIP: Convert projects to project.json #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,13 @@ registered_data.ini
.vs/
module/

project.lock.json

docs/_site/
docs/_repo/
docs/metadata/
tools/

# quickbuild.exe
/VersionGeneratingLogs/
QLogs
QLocal
QTestLogs

# bad tlb/chm generators in nmake tree
*.tlb
*.chm

# dumb silverlight
ClientBin/

# dump azure
*.build.csdef
csx/

# Don't include ScriptAnalyzer binaries
PowerShellEditorServices/**
PowerShellEditorServices.NoNano/**

PowerShellEditorServices.sln.ide/edb.chk
PowerShellEditorServices.sln.ide/edbres00001.jrs
PowerShellEditorServices.sln.ide/storage.ide
Expand Down
22 changes: 22 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "0.1.0",
"command": "powershell",
"isShellCommand": true,
"showOutput": "always",
"suppressTaskName": true,
"args": [ "-File" ],

"tasks": [
{
"taskName": "build",
"args": [ "./build.ps1" ],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
},
{
"taskName": "test",
"args": [ "./scripts/RunTests.ps1" ],
"isTestCommand": true,
"problemMatcher": "$msCompile"
}
]
29 changes: 6 additions & 23 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,11 @@ branches:
#init:
#- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

assembly_info:
patch: true
file: '**\AssemblyInfo.*'
assembly_version: '{version}'
assembly_file_version: '{version}'
assembly_informational_version: '$(core_version)$(prerelease_name)+{build}'
build_script:
- ps: ./build.ps1 -Configuration Release -BuildNumber $env:APPVEYOR_BUILD_NUMBER -PackageNuget -PackageModule

install:
- git submodule -q update --init
after_build:
- ps: Get-ChildItem -Path "release/BuiltPackages/*" -Include "*.nupkg", "*.zip" | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }

before_build:
- ps: if (Test-Path 'C:\Tools\NuGet3') { $nugetDir = 'C:\Tools\NuGet3' } else { $nugetDir = 'C:\Tools\NuGet' }; (New-Object Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/v3.3.0/nuget.exe', "$nugetDir\NuGet.exe")
- nuget restore PowerShellEditorServices.sln

build:
project: PowerShellEditorServices.NoNano.sln
publish_nuget: true
verbosity: minimal

test:
assemblies:
- Microsoft.PowerShell.EditorServices.Test.dll
- Microsoft.PowerShell.EditorServices.Test.Protocol.dll
- Microsoft.PowerShell.EditorServices.Test.Host.dll
- Microsoft.PowerShell.EditorServices.Test.Channel.WebSockets.dll
test_script:
- ps: ./scripts/RunTests.ps1 -Framework net451 -Configuration Release
132 changes: 132 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
param(
[ValidateSet("net451", "netstandard1.6")]
[string[]]$Frameworks = $null,

[ValidateSet("Debug", "Release")]
[string]$Configuration = "Debug",

[string]$BuildNumber = "0",

[switch]$ForceRestore,
[switch]$PackageNuget,
[switch]$PackageModule
)

$releasePath = Join-Path $PSScriptRoot "release"
$packagesPath = Join-Path $releasePath "BuiltPackages"
$modulePath = Join-Path $PSScriptRoot "module/PowerShellEditorServices"

if ($Frameworks -eq $null) {
if ($IsLinux -or $IsOSX) {
# Running in PowerShell on *NIX
$Frameworks = @("netstandard1.6")
}
else {
# Running in PowerShell on Windows
$Frameworks = @("net451", "netstandard1.6")
}
}

$projectPaths = @(
"src/PowerShellEditorServices",
"src/PowerShellEditorServices.Protocol",
"src/PowerShellEditorServices.Host"
#"src/PowerShellEditorServices.Channel.WebSocket"
)

$testProjectPaths = @(
"test/PowerShellEditorServices.Test.Runner",
"test/PowerShellEditorServices.Test.Shared",
"test/PowerShellEditorServices.Test"
#"test/PowerShellEditorServices.Test.Protocol",
#"test/PowerShellEditorServices.Test.Host"
)

$allProjectPaths = $projectPaths + $testProjectPaths

function Invoke-ProjectBuild($projectPath, $framework) {
$fullPath = Join-Path $PSScriptRoot $projectPath

if ($ForceRestore.IsPresent -or !(Test-Path (Join-Path $fullPath "project.lock.json"))) {
Write-Host "`nRestoring packages for project '$projectPath'" -ForegroundColor Yellow
Push-Location $fullPath
& dotnet restore | Out-Null
Pop-Location

if ($LASTEXITCODE -ne 0) {
return $false
}
}

Write-Host "`nBuilding project '$projectPath' for framework '$framework'..." -ForegroundColor Yellow
$fullPath = Join-Path $PSScriptRoot -ChildPath $projectPath
Push-Location $fullPath
& dotnet build --framework $framework --configuration $Configuration --version-suffix $BuildNumber --no-dependencies | Out-Null
Pop-Location

return $LASTEXITCODE -eq 0
}

$success = $true
:buildLoop foreach ($projectPath in $allProjectPaths) {
foreach ($framework in $Frameworks) {
if (!(Invoke-ProjectBuild $projectPath $framework $Configuration)) {
Write-Host "`nBuild failed, terminating.`n" -ForegroundColor Red
$success = $false
break buildLoop
}
}
}

if (!$success) {
# Error has already been written, make sure to return
# a non-zero exit code
exit 1
}

foreach ($framework in $Frameworks) {
Write-Host "`nCopying '$framework' binaries to module path..." -ForegroundColor Yellow

$hostBinaryPath = Join-Path $PSScriptRoot "src/PowerShellEditorServices.Host/bin/$Configuration/$framework/*"
$moduleFrameworkPath = Join-Path $modulePath $framework
New-Item -ItemType Directory $moduleFrameworkPath -Force | Out-Null
Copy-Item -Path $hostBinaryPath -Include "*.dll", "*.pdb" -Destination $moduleFrameworkPath -Force
}

# Ensure the packages path exists
if ($PackageModule.IsPresent -or $PackageNuget.IsPresent) {
New-Item -ItemType Directory $packagesPath -Force | Out-Null
}

if ($PackageModule.IsPresent) {
Write-Host "`nCreating module package..." -ForegroundColor Yellow

# TODO: Put version in package name
$modulePackageName = Join-Path $packagesPath -ChildPath "PowerShellEditorServices-module.zip"
Compress-Archive -Path $modulePath -DestinationPath $modulePackageName -Force

# TODO: Handle failure!
}

if ($PackageNuget.IsPresent) {
Write-Host "`nCreating NuGet packages..." -ForegroundColor Yellow

foreach ($projectPath in $projectPaths) {
Push-Location (Join-Path $PSScriptRoot $projectPath)
& dotnet pack -o $packagesPath --no-build --configuration $Configuration --version-suffix $BuildNumber | Out-Null
Pop-Location

if ($LASTEXITCODE -ne 0) {
$success = $false
break
}
}
}

if (!$success) {
# Error has already been written, make sure to return
# a non-zero exit code
exit 1
}

Write-Host "`nBuild succeeded!`n" -ForegroundColor Green
3 changes: 3 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"projects": [ "src" ]
}
12 changes: 12 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<!-- install packages to a custom path -->
<add key="repositoryPath" value="Packages"/>
</config>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="powershell-core" value="https://powershell.myget.org/F/powershell-core/api/v3/index.json" />
</packageSources>
</configuration>
77 changes: 77 additions & 0 deletions scripts/RunTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
param(
[string[]]$TestProjects = @(
"PowerShellEditorServices.Test",
"PowerShellEditorServices.Test.Protocol",
"PowerShellEditorServices.Test.Host"
),

[ValidateSet("net451", "netstandard1.6")]
[string]$Framework = "netstandard1.6",

[ValidateSet("Debug", "Release")]
[string]$Configuration = "Debug",

[switch]$AppVeyorMode
)

$xunitVersion = "2.2.0-*"

#$nugetPackagesPath = "$HOME/.nuget/packages"
#$testRunnerPath = Join-Path $PSScriptRoot, ".." "test/PowerShellEditorServices.Test.Runner"
#$testRunnerBinPath = Join-Path "$testRunnerPath bin/$Configuration/$Framework"
#$testRunnerDllPath = Join-Path $testRunnerBinPath "Microsoft.PowerShell.EditorServices.Test.Runner.dll"

function Copy-TestDependencies($runnerPath) {

# Needed depdenendcies:
# xunit.runner.utility
# xunit.abstrations
# xunit.assert

# TODO: Don't hardcode these paths, resolve them from package.lock.json
if ($Framework -eq "net451") {
cp $HOME/.nuget/packages/xunit.runner.utility/2.2.0-beta2-build3300/lib/net45/xunit.runner.utility.desktop.dll $runnerPath
cp /home/daviwil/.nuget/packages/xunit.abstractions/2.0.1-rc2/lib/net35/xunit.abstractions.dll $runnerPath
}
elseif ($Framework -eq "netstandard1.6") {
cp $HOME/.nuget/packages/xunit.assert/2.2.0-beta2-build3300/lib/netstandard1.0/xunit.assert.dll $runnerPath
cp $HOME/.nuget/packages/xunit.runner.utility/2.2.0-beta2-build3300/lib/netstandard1.1/xunit.runner.utility.dotnet.dll $runnerPath
cp $HOME/.nuget/packages/xunit.abstractions/2.0.1-rc2/lib/netstandard1.0/xunit.abstractions.dll $runnerPath
}

# $xunitPlatform = "dotnet"

# $xunitPaths = Get-ChildItem $nugetPackagesPath -Recurse "2.2.0-*" | % { $_.FullName }
# $xunitDlls = @(
# "xunit.assert.dll",
# "xunit.runner.utility.$xunitPlatform"
# )
# $xunitDllPaths = Get-ChildItem -Path $xunitPaths -Recurse -Include $xunitDlls

# Copy-Item -Path
# #$projectJson = (Get-Content "$testRunnerPath/project.lock.json") -Join "`n" | ConvertFrom-Json

}

# Ideals:
# - Provide paths to test assemblies
# - Optionally specify test classes/names to run
# - Maybe use xunit's resolvers if I can, make my own if not
# - Execute tests sequentially at first, maybe in background later
# - Custom output and error handling to get ideal output
# - Make it possible to use AppVeyor's output system, but if not, use their API:
# https://www.appveyor.com/docs/build-worker-api/#add-tests

# TODO: Might need to load PSES assemblies too...

$runnerBinPath = Join-Path $PSScriptRoot "../test/PowerShellEditorServices.Test.Runner/bin/$Configuration/$Framework/"
Add-Type -Path "$runnerBinPath/Microsoft.PowerShell.EditorServices.Test.Runner.dll"

Copy-TestDependencies $runnerBinPath

$assemblyPath = Join-Path $PSScriptRoot "../test/PowerShellEditorServices.Test/bin/$Configuration/$Framework/Microsoft.PowerShell.EditorServices.Test.dll"
Get-ChildItem $assemblyPath
Write-Host "Running tests for assembly: $assemblyPath" -ForegroundColor Yellow

$runner = [Microsoft.PowerShell.EditorServices.Test.Runner.TestRunner]::new()
$runner.RunTests(@($assemblyPath))
31 changes: 0 additions & 31 deletions src/Microsoft.CoreSys.CSharp.Targets

This file was deleted.

Loading