Skip to content
This repository was archived by the owner on Sep 13, 2019. It is now read-only.

Commit dc34740

Browse files
committed
Use .CodeBase instead of .Location
1 parent 457dd05 commit dc34740

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

Postman.WebApi.MsBuildTask.Tests/GeneratorTests.cs

+11-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public class GeneratorTests
2626
public void creates_postman_collection()
2727
{
2828
// Arrange
29-
var assemblyFilePath = Assembly.GetExecutingAssembly().Location;
29+
var codeBase = new Uri(Assembly.GetExecutingAssembly().CodeBase);
30+
var assemblyFilePath = codeBase.LocalPath;
3031

3132
var generator = new CollectionGenerator();
3233

@@ -48,9 +49,12 @@ public void executes_postman_generatetask()
4849
{
4950
// Arrange
5051
var mock = new Mock<IBuildEngine>();
52+
var codeBase = new Uri(Assembly.GetExecutingAssembly().CodeBase);
53+
var assemblyFilePath = codeBase.LocalPath;
54+
5155
var task = new GenerateTask
5256
{
53-
AssemblyFilePath = Assembly.GetExecutingAssembly().Location,
57+
AssemblyFilePath = assemblyFilePath,
5458
OutputDirectory = @".\",
5559
BuildEngine = mock.Object
5660
};
@@ -71,15 +75,18 @@ public void executes_postman_generatetask()
7175
public void throws_filenotfoundexception_when_no_xml_doc_file_found()
7276
{
7377
// Arrange
78+
var codeBase = new Uri(Assembly.GetExecutingAssembly().CodeBase);
79+
var assemblyFilePath = codeBase.LocalPath;
80+
7481
var mock = new Mock<IBuildEngine>();
7582
GenerateTask task = new GenerateTask
7683
{
77-
AssemblyFilePath = Assembly.GetExecutingAssembly().Location,
84+
AssemblyFilePath = assemblyFilePath,
7885
OutputDirectory = @".\",
7986
BuildEngine = mock.Object
8087
};
8188

82-
var xmlFile = Assembly.GetExecutingAssembly().Location.Replace(Resources.DllFileExtension, Resources.XmlFileExtension);
89+
var xmlFile = task.AssemblyFilePath.Replace(Resources.DllFileExtension, Resources.XmlFileExtension);
8390
var tmpFile = @"tmp.xml";
8491
File.Move(xmlFile, tmpFile);
8592

Postman.WebApi.MsBuildTask/CollectionGenerator.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ public PostmanCollection Create(string assemblyFilePath, string environmentKey,
8080

8181
var baseUrl = "{{" + environmentKey + "}}/";
8282
var assemblyName = Path.GetFileNameWithoutExtension(assemblyFilePath);
83-
var xmlPath = assemblyFilePath.Replace(Resources.DllFileExtension, Resources.XmlFileExtension);
83+
var xmlPath = assemblyFilePath
84+
.ToLowerInvariant()
85+
.Replace(Resources.DllFileExtension, Resources.XmlFileExtension);
8486

8587
if (!File.Exists(xmlPath))
8688
{

Postman.WebApi.MsBuildTask/GenerateTask.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static GenerateTask()
2828
{
2929
// When executed as a task by MSBuild.exe, the configuration file is msbuild.exe.config
3030
// Manually redirect assembly bindings in case the host project has dependencies on differing versions
31-
var configFile = Assembly.GetExecutingAssembly().Location + Resources.ConfigFileExtension;
31+
var configFile = Assembly.GetExecutingAssembly().CodeBase + Resources.ConfigFileExtension;
3232

3333
var appConfig = new AppConfig();
3434
appConfig.Load(configFile);

appveyor.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,8 @@ build:
3939
before_build: nuget restore
4040

4141
on_finish:
42-
- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
42+
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
4343

4444
#---------------------------------#
4545
# tests configuration #
4646
#---------------------------------#
47-
48-
test:
49-
assemblies:
50-
- '**\*.UnitTests.dll'

0 commit comments

Comments
 (0)