Skip to content

Commit d2807b4

Browse files
committed
Fixed bug where signed pkgs were specifying unsigned config section
1 parent c7becdb commit d2807b4

File tree

16 files changed

+252
-27
lines changed

16 files changed

+252
-27
lines changed

appveyor.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pull_requests:
1212
init:
1313
- git config --global core.autocrlf true
1414
- ps: $env:GIT_HASH=$env:APPVEYOR_REPO_COMMIT.Substring(0, 10)
15-
- ps: If ("$env:APPVEYOR_REPO_TAG" -ne "true") { $env:VERSION_SUFFIX="-pre" }
15+
- ps: If ("$env:APPVEYOR_REPO_BRANCH" -ne "master") { $env:VERSION_SUFFIX="-pre" }
1616

1717
assembly_info:
1818
patch: true
@@ -50,8 +50,6 @@ artifacts:
5050
deploy:
5151
- provider: Environment
5252
name: NuGet
53-
on:
54-
branch: master
5553
- provider: GitHub
5654
auth_token:
5755
secure: 0s81q7bweVLTFSOKxnIhan7el6bIFiN8HJ1kYJzOkeFXX7wgGSq9bs/rV53X9qpf
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# Copyright 2016 Exceptionless
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
8+
function find_config($project) {
9+
$configPath = $null
10+
11+
if ($project -eq $null -or $project.ProjectItems -eq $null) {
12+
return $configPath
13+
}
14+
15+
try {
16+
$config = $project.ProjectItems.Item("Web.config")
17+
} catch { }
18+
19+
if ($config -eq $null) {
20+
try {
21+
$config = $project.ProjectItems.Item("App.config")
22+
} catch { }
23+
}
24+
25+
if ($config -ne $null) {
26+
try {
27+
$configPath = $config.Properties.Item("LocalPath").Value
28+
} catch { }
29+
}
30+
31+
return $configPath
32+
}
33+
34+
function update_config($configPath, $platform) {
35+
[xml] $configXml = gc $configPath
36+
$shouldSave = $false
37+
38+
if ($configXml -ne $null) {
39+
$configSection = $configXml.SelectSingleNode("configuration/configSections/section[@name='exceptionless']")
40+
if ($configSection -eq $null) {
41+
$parentNode = $configXml.SelectSingleNode("configuration/configSections")
42+
if ($parentNode -eq $null) {
43+
if($configXml.SelectSingleNode("configuration").ChildNodes.Count -eq 0) {
44+
$parentNode = $configXml.SelectSingleNode("configuration").AppendChild($configXml.CreateElement('configSections'))
45+
} else {
46+
$parentNode = $configXml.SelectSingleNode("configuration").InsertBefore($configXml.CreateElement('configSections'), $configXml.SelectSingleNode("configuration").ChildNodes[0])
47+
}
48+
}
49+
$configSection = $configXml.CreateElement('section')
50+
$configSection.SetAttribute('name', 'exceptionless')
51+
$configSection.SetAttribute('type', 'Exceptionless.ExceptionlessSection, Exceptionless.Signed')
52+
53+
$parentNode.AppendChild($configSection)
54+
$shouldSave = $true
55+
}
56+
57+
$exceptionlessConfig = $configXml.SelectSingleNode("configuration/exceptionless")
58+
if ($exceptionlessConfig -eq $null) {
59+
$exceptionlessNode = $configXml.CreateElement('exceptionless')
60+
$exceptionlessNode.SetAttribute('apiKey', 'API_KEY_HERE')
61+
62+
$target = $configXml.configuration['system.web']
63+
$configXml.SelectSingleNode("configuration").InsertBefore($exceptionlessNode, $target)
64+
$shouldSave = $true
65+
} else {
66+
if ($exceptionlessConfig.HasAttribute('queuePath')) {
67+
$exceptionlessConfig.SetAttribute('storagePath', $exceptionlessConfig.GetAttribute('queuePath'))
68+
$exceptionlessConfig.RemoveAttribute('queuePath')
69+
$shouldSave = $true
70+
}
71+
72+
$extendedData = $exceptionlessConfig.SelectSingleNode('extendedData')
73+
if ($extendedData -ne $null) {
74+
$data = $configXml.CreateElement('data')
75+
$data.InnerXML = $extendedData.InnerXML
76+
$exceptionlessConfig.AppendChild($data)
77+
$exceptionlessConfig.RemoveChild($extendedData)
78+
79+
$shouldSave = $true
80+
}
81+
}
82+
83+
if ($platform -ne $null -and $platform -ne 'WebApi') {
84+
$webServerModule = $configXml.SelectSingleNode("configuration/system.webServer/modules/add[@name='ExceptionlessModule']")
85+
if ($webServerModule -eq $null) {
86+
$parentNode = $configXml.SelectSingleNode("configuration/system.webServer")
87+
if ($parentNode -eq $null) {
88+
$parentNode = $configXml.SelectSingleNode("configuration").AppendChild($configXml.CreateElement('system.webServer'))
89+
}
90+
$parentNode = $configXml.SelectSingleNode("configuration/system.webServer/modules")
91+
if ($parentNode -eq $null) {
92+
$parentNode = $configXml.configuration['system.webServer'].AppendChild($configXml.CreateElement('modules'))
93+
}
94+
$webServerModule = $configXml.CreateElement('add')
95+
$webServerModule.SetAttribute('name', 'ExceptionlessModule')
96+
$webServerModule.SetAttribute('type', 'Exceptionless.' + $platform + '.ExceptionlessModule, Exceptionless.' + $platform)
97+
98+
$parentNode.AppendChild($webServerModule)
99+
$shouldSave = $true
100+
}
101+
}
102+
103+
if ($shouldSave -eq $true) {
104+
$configXml.Save($configPath)
105+
}
106+
}
107+
}
108+
109+
function remove_config($configPath, $platform) {
110+
[xml] $configXml = gc $configPath
111+
$shouldSave = $false
112+
113+
if ($configXml -ne $null) {
114+
$configSection = $configXml.SelectSingleNode("configuration/configSections/section[@name='exceptionless']")
115+
if ($configSection -ne $null) {
116+
[Void]$configSection.ParentNode.RemoveChild($configSection)
117+
$shouldSave = $true
118+
}
119+
120+
$configSection = $configXml.SelectSingleNode("configuration/exceptionless")
121+
if ($configSection -ne $null) {
122+
if ($configSection.HasAttribute("apiKey") -and ($configSection.GetAttribute("apiKey") -ne 'API_KEY_HERE') -and ($configSection.GetAttribute("apiKey").length -gt 10)) {
123+
"Exceptionless API Key has been configured and will not be removed."
124+
} else {
125+
[Void]$configSection.ParentNode.RemoveChild($configSection)
126+
$shouldSave = $true
127+
}
128+
}
129+
130+
if ($platform -ne $null -and $platform -ne 'WebApi') {
131+
$webModule = $configXml.SelectSingleNode("configuration/system.web/httpModules/add[@name='ExceptionlessModule']")
132+
if ($webModule -ne $null) {
133+
[Void]$webModule.ParentNode.RemoveChild($webModule)
134+
$shouldSave = $true
135+
}
136+
137+
$webServerModule = $configXml.SelectSingleNode("configuration/system.webServer/modules/add[@name='ExceptionlessModule']")
138+
if ($webServerModule -ne $null) {
139+
[Void]$webServerModule.ParentNode.RemoveChild($webServerModule)
140+
$shouldSave = $true
141+
}
142+
}
143+
144+
145+
if ($shouldSave -eq $true) {
146+
$configXml.Save($configPath)
147+
}
148+
}
149+
}
150+
151+
function add_attribute($sourceFile) {
152+
if (!(test-path $sourceFile)) {
153+
return
154+
}
155+
156+
$input = get-content $sourceFile
157+
$isUpdated = $input | Select-String "Exceptionless" -quiet
158+
159+
if ($isUpdated) {
160+
return
161+
}
162+
163+
# seems to insure a linefeed
164+
"" | Out-file $sourceFile -append
165+
if ([string]$sourceFile.EndsWith('.vb')) {
166+
'<assembly: Exceptionless.Configuration.Exceptionless("API_KEY_HERE")>' | Out-File $sourceFile -append
167+
} else {
168+
'[assembly: Exceptionless.Configuration.Exceptionless("API_KEY_HERE")]' | Out-File $sourceFile -append
169+
}
170+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
param($installPath, $toolsPath, $package, $project)
2+
3+
Import-Module (Join-Path $toolsPath exceptionless.psm1)
4+
5+
$configPath = find_config $project
6+
7+
if ($configPath -ne $null) {
8+
update_config $configPath
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
param($installPath, $toolsPath, $package, $project)
2+
3+
Import-Module (Join-Path $toolsPath exceptionless.psm1)
4+
5+
$configPath = find_config $project
6+
7+
if ($configPath -ne $null) {
8+
remove_config $configPath
9+
}

src/Exceptionless.Signed/project.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
"url": "https://github.com/exceptionless/Exceptionless.Net"
3333
},
3434
"files": {
35-
"include": [
36-
"../Exceptionless/readme.txt"
37-
]
35+
"mappings": {
36+
"tools/": "NuGet/tools/*",
37+
"readme.txt": "../Exceptionless/readme.txt"
38+
}
3839
}
3940
},
4041
"buildOptions": {

src/Exceptionless.Tests/project.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99
},
1010
"dependencies": {
11-
"BenchmarkDotNet": "0.9.7",
11+
"BenchmarkDotNet": "0.9.8",
1212
"Exceptionless": {
1313
"target": "project"
1414
},
@@ -22,6 +22,17 @@
2222
"Exceptionless.RandomData": "1.1.24"
2323
},
2424
"frameworks": {
25+
//"netcoreapp1.0": {
26+
// "buildOptions": {
27+
// "define": [ "NETSTANDARD", "NETSTANDARD1_5" ]
28+
// },
29+
// "dependencies": {
30+
// "Microsoft.NETCore.App": {
31+
// "type": "platform",
32+
// "version": "1.0.0"
33+
// }
34+
// }
35+
//},
2536
"NET46": {
2637
"buildOptions": {
2738
"define": [ "NET46" ]

src/Exceptionless/NuGet/tools/exceptionless.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2014 Exceptionless
1+
# Copyright 2016 Exceptionless
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

src/Exceptionless/project.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
"url": "https://github.com/exceptionless/Exceptionless.Net"
3333
},
3434
"files": {
35+
"mappings": {
36+
"tools/": "NuGet/tools/*"
37+
},
3538
"include": [
3639
"readme.txt"
3740
]

src/Platforms/Exceptionless.AspNetCore.Signed/project.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
"url": "https://github.com/exceptionless/Exceptionless.Net"
3131
},
3232
"files": {
33-
"include": [
34-
"../Exceptionless.AspNetCore/readme.txt"
35-
]
33+
"mappings": {
34+
"readme.txt": "../Exceptionless.AspNetCore/readme.txt"
35+
}
3636
}
3737
},
3838
"buildOptions": {

src/Platforms/Exceptionless.Log4net.Signed/project.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"url": "https://github.com/exceptionless/Exceptionless.Net"
1717
},
1818
"files": {
19-
"include": [ "../Exceptionless.Log4net/readme.txt" ]
19+
"mappings": {
20+
"readme.txt": "../Exceptionless.Log4net/readme.txt"
21+
}
2022
}
2123
},
2224
"dependencies": {

0 commit comments

Comments
 (0)