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

Commit

Permalink
Use .CodeBase instead of .Location
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesholcomb committed Nov 12, 2015
1 parent 457dd05 commit dc34740
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
15 changes: 11 additions & 4 deletions Postman.WebApi.MsBuildTask.Tests/GeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public class GeneratorTests
public void creates_postman_collection()
{
// Arrange
var assemblyFilePath = Assembly.GetExecutingAssembly().Location;
var codeBase = new Uri(Assembly.GetExecutingAssembly().CodeBase);
var assemblyFilePath = codeBase.LocalPath;

var generator = new CollectionGenerator();

Expand All @@ -48,9 +49,12 @@ public void executes_postman_generatetask()
{
// Arrange
var mock = new Mock<IBuildEngine>();
var codeBase = new Uri(Assembly.GetExecutingAssembly().CodeBase);
var assemblyFilePath = codeBase.LocalPath;

var task = new GenerateTask
{
AssemblyFilePath = Assembly.GetExecutingAssembly().Location,
AssemblyFilePath = assemblyFilePath,
OutputDirectory = @".\",
BuildEngine = mock.Object
};
Expand All @@ -71,15 +75,18 @@ public void executes_postman_generatetask()
public void throws_filenotfoundexception_when_no_xml_doc_file_found()
{
// Arrange
var codeBase = new Uri(Assembly.GetExecutingAssembly().CodeBase);
var assemblyFilePath = codeBase.LocalPath;

var mock = new Mock<IBuildEngine>();
GenerateTask task = new GenerateTask
{
AssemblyFilePath = Assembly.GetExecutingAssembly().Location,
AssemblyFilePath = assemblyFilePath,
OutputDirectory = @".\",
BuildEngine = mock.Object
};

var xmlFile = Assembly.GetExecutingAssembly().Location.Replace(Resources.DllFileExtension, Resources.XmlFileExtension);
var xmlFile = task.AssemblyFilePath.Replace(Resources.DllFileExtension, Resources.XmlFileExtension);
var tmpFile = @"tmp.xml";
File.Move(xmlFile, tmpFile);

Expand Down
4 changes: 3 additions & 1 deletion Postman.WebApi.MsBuildTask/CollectionGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public PostmanCollection Create(string assemblyFilePath, string environmentKey,

var baseUrl = "{{" + environmentKey + "}}/";
var assemblyName = Path.GetFileNameWithoutExtension(assemblyFilePath);
var xmlPath = assemblyFilePath.Replace(Resources.DllFileExtension, Resources.XmlFileExtension);
var xmlPath = assemblyFilePath
.ToLowerInvariant()
.Replace(Resources.DllFileExtension, Resources.XmlFileExtension);

if (!File.Exists(xmlPath))
{
Expand Down
2 changes: 1 addition & 1 deletion Postman.WebApi.MsBuildTask/GenerateTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static GenerateTask()
{
// When executed as a task by MSBuild.exe, the configuration file is msbuild.exe.config
// Manually redirect assembly bindings in case the host project has dependencies on differing versions
var configFile = Assembly.GetExecutingAssembly().Location + Resources.ConfigFileExtension;
var configFile = Assembly.GetExecutingAssembly().CodeBase + Resources.ConfigFileExtension;

var appConfig = new AppConfig();
appConfig.Load(configFile);
Expand Down
6 changes: 1 addition & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,8 @@ build:
before_build: nuget restore

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

#---------------------------------#
# tests configuration #
#---------------------------------#

test:
assemblies:
- '**\*.UnitTests.dll'

0 comments on commit dc34740

Please sign in to comment.