0

I am using Powershell for Build Deployment. I am struggling with this line of the code:

$pubsettings  = "\\Myserver\AzureScripts\default.publishsettings"
Import-AzurePublishSettingsFile $pubsettings

\\Myserver\AzureScripts\default.publishsettings actually maps to D:\\AzureScripts\default.publishsettings on MyServer

Following are scenarios:

  1. Working directory = \\Myserver\AzureScripts and $pubsettings = "\\Myserver\AzureScripts\default.publishsettings"
    Result: File Not Found (System.Exception)

  2. Working directory = \\Myserver\AzureScripts and $pubsettings = "D:\\AzureScripts\default.publishsettings"
    Result: File Not Found (System.Exception)

  3. Working directory = D:\\AzureScripts and $pubsettings = "D:\\AzureScripts\default.publishsettings"
    Result: File Not Found (System.Exception)

  4. Working directory = D:\\AzureScripts and $pubsettings = "\\Myserver\AzureScripts\default.publishsettings"
    Result: File Not Found (System.Exception)

  5. Working directory = \\Myserver\AzureScripts and $pubsettings = ".\default.publishsettings"
    Result: File Not Found (System.Exception)

  6. Working directory = D:\\AzureScripts and $pubsettings = ".\default.publishsettings"
    Result: Sucessfully File is imported

So My Questions are:
Why First five scenarios are failing and only sixth is passing even though all are equivalent?
How do make 6th case to work like 1st scenario using absolute UNC path?

userda
  • 595
  • 5
  • 15

1 Answers1

0

Try this:

Add-AzureAccount
Get-AzurePublishSettingsFile 
Import-AzurePublishSettingsFile "C:\AZURE\azure\xyz.publishsettings"

with xyz.publishsetting file being your publishsetting file.

Note here file-path should be inside quotes and there should not be any empty space in between.

AdrieanKhisbe
  • 3,899
  • 8
  • 37
  • 45
Aatif Akhter
  • 2,126
  • 1
  • 25
  • 46