Skip to content

Commit ee8ebb8

Browse files
committed
Convert projects to project.json
This change converts all existing projects to the new project.json format which can build both full CLR and CoreCLR binaries for these assemblies.
1 parent 30f246b commit ee8ebb8

File tree

11 files changed

+249
-161
lines changed

11 files changed

+249
-161
lines changed

.gitignore

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,13 @@ registered_data.ini
2828
.vs/
2929
module/
3030

31+
project.lock.json
32+
3133
docs/_site/
3234
docs/_repo/
3335
docs/metadata/
3436
tools/
3537

36-
# quickbuild.exe
37-
/VersionGeneratingLogs/
38-
QLogs
39-
QLocal
40-
QTestLogs
41-
42-
# bad tlb/chm generators in nmake tree
43-
*.tlb
44-
*.chm
45-
46-
# dumb silverlight
47-
ClientBin/
48-
49-
# dump azure
50-
*.build.csdef
51-
csx/
52-
53-
# Don't include ScriptAnalyzer binaries
54-
PowerShellEditorServices/**
55-
PowerShellEditorServices.NoNano/**
56-
5738
PowerShellEditorServices.sln.ide/edb.chk
5839
PowerShellEditorServices.sln.ide/edbres00001.jrs
5940
PowerShellEditorServices.sln.ide/storage.ide

.vscode/tasks.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": "0.1.0",
3+
"command": "powershell",
4+
"isShellCommand": true,
5+
"showOutput": "always",
6+
"suppressTaskName": true,
7+
"args": [ "-File" ],
8+
9+
"tasks": [
10+
{
11+
"taskName": "build",
12+
"args": [ "./build.ps1" ],
13+
"isBuildCommand": true,
14+
"problemMatcher": "$msCompile"
15+
}
16+
]

appveyor.yml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,27 @@ branches:
2121
#init:
2222
#- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
2323

24-
assembly_info:
25-
patch: true
26-
file: '**\AssemblyInfo.*'
27-
assembly_version: '{version}'
28-
assembly_file_version: '{version}'
29-
assembly_informational_version: '$(core_version)$(prerelease_name)+{build}'
24+
# assembly_info:
25+
# patch: true
26+
# file: '**\AssemblyInfo.*'
27+
# assembly_version: '{version}'
28+
# assembly_file_version: '{version}'
29+
# assembly_informational_version: '$(core_version)$(prerelease_name)+{build}'
3030

3131
install:
3232
- git submodule -q update --init
3333

34-
before_build:
35-
- 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")
36-
- nuget restore PowerShellEditorServices.sln
37-
38-
build:
39-
project: PowerShellEditorServices.NoNano.sln
40-
publish_nuget: true
41-
verbosity: minimal
42-
43-
test:
44-
assemblies:
45-
- Microsoft.PowerShell.EditorServices.Test.dll
46-
- Microsoft.PowerShell.EditorServices.Test.Protocol.dll
47-
- Microsoft.PowerShell.EditorServices.Test.Host.dll
48-
- Microsoft.PowerShell.EditorServices.Test.Channel.WebSockets.dll
34+
# before_build:
35+
# - 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")
36+
# - nuget restore PowerShellEditorServices.sln
37+
38+
build_script:
39+
- ps: |
40+
./build.ps1 -Configuration Release -BuildNumber $env:APPVEYOR_BUILD_NUMBER -PackageNuget -PackageModule
41+
42+
# test:
43+
# assemblies:
44+
# - Microsoft.PowerShell.EditorServices.Test.dll
45+
# - Microsoft.PowerShell.EditorServices.Test.Protocol.dll
46+
# - Microsoft.PowerShell.EditorServices.Test.Host.dll
47+
# - Microsoft.PowerShell.EditorServices.Test.Channel.WebSockets.dll

build.ps1

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
param(
2+
[ValidateSet("net451", "netstandard1.6")]
3+
[string[]]$Frameworks = $null,
4+
5+
[ValidateSet("Debug", "Release")]
6+
[string]$Configuration = "Debug",
7+
8+
[string]$BuildNumber = "0",
9+
10+
[switch]$ForceRestore,
11+
[switch]$PackageNuget,
12+
[switch]$PackageModule
13+
)
14+
15+
$releasePath = Join-Path $PSScriptRoot "release"
16+
$packagesPath = Join-Path $releasePath "BuiltPackages"
17+
$modulePath = Join-Path $PSScriptRoot "module/PowerShellEditorServices"
18+
19+
if ($Frameworks -eq $null) {
20+
if ($IsLinux -or $IsOSX) {
21+
# Running in PowerShell on *NIX
22+
$Frameworks = @("netstandard1.6")
23+
}
24+
else {
25+
# Running in PowerShell on Windows
26+
$Frameworks = @("net451", "netstandard1.6")
27+
}
28+
}
29+
30+
$projectPaths = @(
31+
"src/PowerShellEditorServices",
32+
"src/PowerShellEditorServices.Protocol",
33+
"src/PowerShellEditorServices.Host"
34+
#"src/PowerShellEditorServices.Channel.WebSocket"
35+
)
36+
37+
$testProjectPaths = @(
38+
#"test/PowerShellEditorServices.Test",
39+
#"test/PowerShellEditorServices.Test.Protocol",
40+
#"test/PowerShellEditorServices.Test.Host"
41+
)
42+
43+
$allProjectPaths = $projectPaths + $testProjectPaths
44+
45+
function Invoke-ProjectBuild($projectPath, $framework) {
46+
$fullPath = Join-Path $PSScriptRoot $projectPath
47+
48+
if ($ForceRestore.IsPresent -or !(Test-Path (Join-Path $fullPath "project.lock.json"))) {
49+
Write-Host "`nRestoring packages for project '$projectPath'" -ForegroundColor Yellow
50+
Push-Location $fullPath
51+
& dotnet restore | Out-Null
52+
Pop-Location
53+
54+
if ($LASTEXITCODE -ne 0) {
55+
return $false
56+
}
57+
}
58+
59+
Write-Host "`nBuilding project '$projectPath' for framework '$framework'..." -ForegroundColor Yellow
60+
$fullPath = Join-Path $PSScriptRoot -ChildPath $projectPath
61+
Push-Location $fullPath
62+
& dotnet build --framework $framework --configuration $Configuration --version-suffix $BuildNumber --no-dependencies | Out-Null
63+
Pop-Location
64+
65+
return $LASTEXITCODE -eq 0
66+
}
67+
68+
$success = $true
69+
:buildLoop foreach ($projectPath in $allProjectPaths) {
70+
foreach ($framework in $Frameworks) {
71+
if (!(Invoke-ProjectBuild $projectPath $framework $Configuration)) {
72+
Write-Host "`nBuild failed, terminating.`n" -ForegroundColor Red
73+
$success = $false
74+
break buildLoop
75+
}
76+
}
77+
}
78+
79+
if (!$success) {
80+
# Error has already been written, make sure to return
81+
# a non-zero exit code
82+
exit 1
83+
}
84+
85+
foreach ($framework in $Frameworks) {
86+
Write-Host "`nCopying '$framework' binaries to module path..." -ForegroundColor Yellow
87+
88+
$hostBinaryPath = Join-Path $PSScriptRoot "src/PowerShellEditorServices.Host/bin/$Configuration/$framework/*"
89+
$moduleFrameworkPath = Join-Path $modulePath $framework
90+
New-Item -ItemType Directory $moduleFrameworkPath -Force | Out-Null
91+
Copy-Item -Path $hostBinaryPath -Include "*.dll", "*.pdb" -Destination $moduleFrameworkPath -Force
92+
}
93+
94+
# Ensure the packages path exists
95+
if ($PackageModule.IsPresent -or $PackageNuget.IsPresent) {
96+
New-Item -ItemType Directory $packagesPath -Force | Out-Null
97+
}
98+
99+
if ($PackageModule.IsPresent) {
100+
Write-Host "`nCreating module package..." -ForegroundColor Yellow
101+
102+
# TODO: Put version in package name
103+
$modulePackageName = Join-Path $packagesPath -ChildPath "PowerShellEditorServices-module.zip"
104+
Compress-Archive -Path $modulePath -DestinationPath $modulePackageName -Force
105+
106+
# TODO: Handle failure!
107+
}
108+
109+
if ($PackageNuget.IsPresent) {
110+
Write-Host "`nCreating NuGet packages...`n" -ForegroundColor Yellow
111+
112+
foreach ($projectPath in $projectPaths) {
113+
Push-Location (Join-Path $PSScriptRoot $projectPath)
114+
& dotnet pack -o $packagesPath --no-build --configuration $Configuration --version-suffix $BuildNumber | Out-Null
115+
Pop-Location
116+
117+
if ($LASTEXITCODE -ne 0) {
118+
$success = false
119+
break
120+
}
121+
}
122+
}
123+
124+
if (!$success) {
125+
# Error has already been written, make sure to return
126+
# a non-zero exit code
127+
exit 1
128+
}
129+
130+
Write-Host "`nBuild succeeded!`n" -ForegroundColor Green

global.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"projects": [ "src" ]
3+
}

nuget.config

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<config>
4+
<!-- install packages to a custom path -->
5+
<add key="repositoryPath" value="Packages"/>
6+
</config>
7+
<packageSources>
8+
<clear />
9+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
10+
<add key="powershell-core" value="https://powershell.myget.org/F/powershell-core/api/v3/index.json" />
11+
</packageSources>
12+
</configuration>

src/Microsoft.CoreSys.CSharp.Targets

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/Microsoft.Coresys.Common.Targets

Lines changed: 0 additions & 88 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "Microsoft.PowerShell.EditorServices.Host",
3+
"version": "0.7.1-beta-*",
4+
"dependencies": {
5+
"Microsoft.PowerShell.SDK": "1.0.0-alpha9",
6+
"PowerShellEditorServices": "0.7.1-beta-*",
7+
"PowerShellEditorServices.Protocol": "0.7.1-beta-*"
8+
},
9+
"frameworks": {
10+
"net451": {
11+
"buildOptions": {
12+
"define": [ "PowerShellv5r2", "PowerShellv5" ]
13+
}
14+
},
15+
"netstandard1.6": {
16+
"imports": ["dnxcore50", "portable-net45+win8"],
17+
"buildOptions": {
18+
"define": [ "NanoServer", "PowerShellv5r2", "PowerShellv5" ]
19+
}
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)