Powershell to copy files to my deploy directory

steven.roberts's Avatar

steven.roberts

24 Sep, 2019 11:28 PM

Hello,

I am just finalizing our build and deploy scripts in AppVeyor and I have one last thing that I need to do. The following is an example of a deploy.ps1 file I use to complete the deploy.

#
# deploy.ps1
#
$currentDirectory = [IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Path)
# get the full path and file name of the appsettings file in the same directory as this script
$appSettingsFile = [IO.Path]::Combine($currentDirectory, 'appsettings.json')

$appSettingsSource = $env:WebAppSettingsPath

Write-Host $appSettingsSource
Write-Host $appSettingsFile

Copy-Item  -Path $appSettingsSource -Destination $appSettingsFile

the source environment variable looks like this

"C:\AppSettings\WebAppSettings.json" (including "). I'm getting the following error

Copy-Item : Cannot find drive. A drive with the name '"C' does not exist.
At C:\inetpub\dev\deploy.ps1:10 char:1
+ Copy-Item $appSettingsSource $appSettingsFile
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: ("C:String) [Copy-Item], DriveNo 
   tFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.Copy 
   ItemCommand
 ```
  1. 1 Posted by steven.roberts on 24 Sep, 2019 11:36 PM

    steven.roberts's Avatar

    ooops! looks like I just needed to remove the double quotes! Thank you!

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac