none
Psake Script Error in deploy.ps1 file RRS feed

  • Question

  • Hi all,

    I am getting below error. I revert my changes in web.config file but still, the same error, what is the root cause of this please help.

    here is my script -
        Task PublishWeb {
    Invoke-XmlPreprocess "$releaseArtifacts/$webName/Web.Config" $configurationEnvironmentVariables.Keys
            
    "$releaseArtifacts/$webName" `
            "$webservicesPath/$webName/$uniqueDeploymentPath" `
            "$webName.$env:ConfigurationEnvironment" `
            -IdentityType LocalSystem `
            -IdleTimeout ([TimeSpan]::FromDays(1))
    }

    Error

    14:53:24.044 At D:\GoAgent\pipelines\EMSWeb.Deploy.Dev\ReleaseArtifacts\deploy.ps1:103 char:23
    14:53:24.044  +  Invoke-XmlPreprocess "$releaseArtifacts/$webName/Web.Config" $configurationEnvi ...
    14:53:24.044  +                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [<<==>>] 
    Exception: Cannot validate argument on parameter 'private:configFile'. The " Test-Path $_ -PathType Leaf " validation script for the argument with value "D:\GoAgent\pipelines\EMSWeb.Deploy.Dev\ReleaseArtifacts/MS/Web.Config" did not return a result of True. Determine why the validation script failed, and then try the command again. --> The " Test-Path $_ -PathType Leaf " validation script for the argument with value "D:\GoAgent\pipelines\EMSWeb.Deploy.Dev\ReleaseArtifacts/MS/Web.Config" did not return a result of True.
     Determine why the validation script failed, and then try the command again.
    • Moved by Bill_Stewart Friday, March 15, 2019 6:20 PM This is not "fix/debug/rewrite my script for me" forum
    Tuesday, January 22, 2019 10:18 PM

All replies

  • Your script makes little sense and does not match the error.

    When posting scripts in tech forums you must use the code posting too so your script can be read.  Your post is not readable.


    \_(ツ)_/

    Tuesday, January 22, 2019 10:29 PM
  • I asked you to pleas use the code posting tool provided.  Can you please edit your post and fix.

    When I asked for code I asked for PowerShell code and not your web.config.


    \_(ツ)_/


    • Edited by jrv Tuesday, January 22, 2019 11:05 PM
    Tuesday, January 22, 2019 11:04 PM
  • <#
        .SYNOPSIS
          This is a deployment script implemented using <g class="gr_ gr_152 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" data-gr-id="152" id="152">psake</g>.
    #>
    
    #Requires -Version 3.0
    Set-StrictMode -Version Latest
    
    #region Import External Scripts and Modules
    $private:thisScriptDirectory = Split-Path $psake.build_script_file
    $releaseArtifacts = $thisScriptDirectory
    $buildSystem = "$releaseArtifacts/packages/BuildSystem/tools"
    
    Import-Module $buildSystem/BuildSystem.ConfigurationManagement.psm1
    Import-Module $buildSystem/BuildSystem.WebDeploy.psm1
    Import-Module $buildSystem/BuildSystem.Test.psm1
    Import-Module $buildSystem/BuildSystem.NuGetPackagePublishing.psm1
    #endregion
    
    Properties {
        #Declare enviroment variables used by the deployment, including with XmlPreprocess.
        #The default values are --ignored-- except when testing deployments locally.
        $configurationEnvironmentVariables = `
        @{
            'GO_PIPELINE_NAME'='Deploy.Local'
            'GO_PIPELINE_LABEL' = '0.0.0.0';
            'GO_PIPELINE_COUNTER' = '0';
            'GO_STAGE_COUNTER' = $((Get-Date).Ticks);
            'ConfigurationEnvironment' = '_';
            'ApplicationVersion'= '_';
    
            #The custom environment variables below need to be specified in the deployment pipeline
            'AudienceWebApiBaseUrl' = '';
            'ContentManagementWebApiBaseUrl' = '';
            'TS_NUGET_REPOSITORY' = "file://$env:TEMP/nuget_tmp_repository/.";
    #'TS_NUGET_REPOSITORY' = "file://c:/nuget_tmp_repository/.";
            'BaseUrl' = '';
            'EmsUsers' = whoami;
    'EnterpriseMessagingSystemConnectionString' = "replset1";
    'EnterpriseMessagingSystemDatabase' = "";
    
    'Connection' = "eplset1";
    'Database' = "Platform";
    
            'ElasticsearchUrl'= '9200';
            'TravelContactDataAuthCode'= '1B0-CDD6CD801711';
            'TravelContactDataUrl'= 'Retrieve';
            'CityCodeBaseURL'='';
            'BusinessClassBookingCodes'='J,JN,C,D,Z,ZN,P,PN,PZ,IN,I';
    
            'PremiumPlusBookingCodes'='O,ON,A,R,RN';
    'EconomyBookingCodes'='Y,YN,B,M,E,U,H,HN,Q,V,W,S,T,L,K,G,N,XN,X';
    'AirportLookUpURL'='referencedata';
    'CountryCityService'='com';
    'TokenService'='Service.Dev';
    'CountryCodeBaseURL'='.com';
    'ServicesDiscoveryUrl'='nfiguration';
    'ServicesEnforcementUrl'='com';
    
    }
    
        if (!$env:GO_PIPELINE_NAME) 
        {
            Set-EnvironmentVariableDefaultValues $configurationEnvironmentVariables
        }
    
        # Using Convention: The part of the pipeline name after the last dot is the
        # configuration environment (i.e. MyApp.Deploy.Local, Dev, Test, Stage or Prod).
        $env:ConfigurationEnvironment = ($env:GO_PIPELINE_NAME -split '\.')[-1]
    
        $env:ApplicationVersion = $env:GO_PIPELINE_LABEL
        $uniqueDeploymentPath = "$env:GO_PIPELINE_NAME-$env:GO_PIPELINE_LABEL-$env:GO_PIPELINE_COUNTER.$env:GO_STAGE_COUNTER"
        $author = ''
        $copyright = "Copyright (c) $((Get-Date).year)"
        $dataDrive = If (Test-Path 'D:') {'D:'} Else {$env:SystemDrive}
        $webservicesPath = "$dataDrive/web"
        $nugetCommand = "$releaseArtifacts/.nuget/NuGet.exe"
        $webName = 'MS'
    $Database = "latform"
    $Connection = "atform?replicaSet=dev_replset1"
        $nugetCommand = "$releaseArtifacts/.nuget/NuGet.exe"
        $createReleaseNuGetPackage = [System.Convert]::ToBoolean($env:ReleasePackage)
    }
    
    Task Default -Depends Deploy
    
    Task Clean -Depends CleanCreatedNuGetPackages
    
    Task CleanAll -Depends Clean
    
    Task CleanCreatedNuGetPackages { Remove-Item $releaseArtifacts/*.nupkg -Force -ErrorAction SilentlyContinue }
    
    Task Deploy -<g class="gr_ gr_150 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" data-gr-id="150" id="150">Depends</g> PublishWeb
    
    Task All -<g class="gr_ gr_151 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" data-gr-id="151" id="151">Depends</g> PublishNuGetPackages, Deploy {}
    
    Task PublishWeb {
    Try
    {
        Invoke-XmlPreprocess "$releaseArtifacts/$webName/Web.Config" $configurationEnvironmentVariables.Keys
    
        Publish-<g class="gr_ gr_149 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="149" id="149">WebApplication</g> `
            "$releaseArtifacts/$webName" `
            "$webservicesPath/$webName/$uniqueDeploymentPath" `
            "$webName.$env:ConfigurationEnvironment" `
            -IdentityType LocalSystem `
            -IdleTimeout ([TimeSpan]::FromDays(1))
    }
    Catch
    {
       
    }
    Finally
    {
           $formatstring = "{0}"
       $fields = $_.ErrorDetails.Message
           $formatstring -f $fields
     
        "This script made a read attempt error is $formatstring" | out-file D:\logs\ExpensesScript.log -append
    "This script made a read attempt error is $fields" | out-file D:\logs\ExpensesScript.log -append
    }
    }
    
    Task CreateNuGetPackages -Depends CleanCreatedNuGetPackages {
        $private:packages = "$releaseArtifacts/NuGetPackage/packages"
    
        $private:nuSpecFile = "$packages/MS.Core/United.EMS.Core.nuspec"
        New-NuGetPackage $nuSpecFile $createReleaseNuGetPackage -NuGetExe $nugetCommand
    
        $private:nuSpecFile = "$packages/MS.Domain/United.EMS.Domain.nuspec"
        New-NuGetPackage $nuSpecFile $createReleaseNuGetPackage -NuGetExe $nugetCommand
    
        $private:nuSpecFile = "$packages/MS.Persistence/United.EMS.Persistence.nuspec"
        New-NuGetPackage $nuSpecFile $createReleaseNuGetPackage -NuGetExe $nugetCommand
    }
    
    Task PublishNuGetPackages -Alias NuGet -Depends CreateNuGetPackages {
        $private:nugetRepository = (Get-Childitem env:TS_NUGET_REPOSITORY).Value
        $private:publishToNuGetRepository = (Split-Path $nugetRepository) -Replace '\\', '/'
        $(dir .\*.nupkg) | ForEach { Publish-NuGetPackage $_ $publishToNuGetRepository }
    }
    
    Task AcceptanceTest -Alias Accept {
        $private:testAssemblies = Get-ChildItem $releaseArtifacts -Filter '*Acceptance.Tests.dll' -Recurse |
            Where { (Test-Path ($_.Directory.FullName + "/xunit*.dll")) } |
            ForEach  {$_.FullName}
    
        $private:xunitCommand = "$releaseArtifacts/packages/xunit.runner.console/tools/xunit.console.exe"
        $private:testResultsDirectory = "$releaseArtifacts/TestResults"
        Invoke-xUnit $testAssemblies @('-notrait', 'Category=Broken') -XUnitCommand $xunitCommand -TestResultsDirectory $testResultsDirectory
    }
    
    FormatTaskName { Param($taskName) Write-Host ((("-"*25) + "[{0}]" + ("-"*$(50-$taskName.Length))) -f $taskName) -ForegroundColor Green }
    
    
    
    

    <#
        .SYNOPSIS
          This is a deployment script implemented using <g class="gr_ gr_152 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" data-gr-id="152" id="152">psake</g>.
    #>
    
    #Requires -Version 3.0
    Set-StrictMode -Version Latest
    
    #region Import External Scripts and Modules
    $private:thisScriptDirectory = Split-Path $psake.build_script_file
    $releaseArtifacts = $thisScriptDirectory
    $buildSystem = "$releaseArtifacts/packages/BuildSystem/tools"
    
    Import-Module $buildSystem/BuildSystem.ConfigurationManagement.psm1
    Import-Module $buildSystem/BuildSystem.WebDeploy.psm1
    Import-Module $buildSystem/BuildSystem.Test.psm1
    Import-Module $buildSystem/BuildSystem.NuGetPackagePublishing.psm1
    #endregion
    
    Properties {
        #Declare enviroment variables used by the deployment, including with XmlPreprocess.
        #The default values are --ignored-- except when testing deployments locally.
        $configurationEnvironmentVariables = `
        @{
            'GO_PIPELINE_NAME'='Deploy.Local'
            'GO_PIPELINE_LABEL' = '0.0.0.0';
            'GO_PIPELINE_COUNTER' = '0';
            'GO_STAGE_COUNTER' = $((Get-Date).Ticks);
            'ConfigurationEnvironment' = '_';
            'ApplicationVersion'= '_';
    
            #The custom environment variables below need to be specified in the deployment pipeline
            'AudienceWebApiBaseUrl' = '';
            'ContentManagementWebApiBaseUrl' = '';
            'TS_NUGET_REPOSITORY' = "file://$env:TEMP/nuget_tmp_repository/.";
    #'TS_NUGET_REPOSITORY' = "file://c:/nuget_tmp_repository/.";
            'BaseUrl' = '';
            'EmsUsers' = whoami;
    'EnterpriseMessagingSystemConnectionString' = "replset1";
    'EnterpriseMessagingSystemDatabase' = "";
    
    'Connection' = "eplset1";
    'Database' = "Platform";
    
            'ElasticsearchUrl'= '9200';
            'TravelContactDataAuthCode'= '1B0-CDD6CD801711';
            'TravelContactDataUrl'= 'Retrieve';
            'CityCodeBaseURL'='';
            'BusinessClassBookingCodes'='J,JN,C,D,Z,ZN,P,PN,PZ,IN,I';
    
            'PremiumPlusBookingCodes'='O,ON,A,R,RN';
    'EconomyBookingCodes'='Y,YN,B,M,E,U,H,HN,Q,V,W,S,T,L,K,G,N,XN,X';
    'AirportLookUpURL'='referencedata';
    'CountryCityService'='com';
    'TokenService'='Service.Dev';
    'CountryCodeBaseURL'='.com';
    'ServicesDiscoveryUrl'='nfiguration';
    'ServicesEnforcementUrl'='com';
    
    }
    
        if (!$env:GO_PIPELINE_NAME) 
        {
            Set-EnvironmentVariableDefaultValues $configurationEnvironmentVariables
        }
    
        # Using Convention: The part of the pipeline name after the last dot is the
        # configuration environment (i.e. MyApp.Deploy.Local, Dev, Test, Stage or Prod).
        $env:ConfigurationEnvironment = ($env:GO_PIPELINE_NAME -split '\.')[-1]
    
        $env:ApplicationVersion = $env:GO_PIPELINE_LABEL
        $uniqueDeploymentPath = "$env:GO_PIPELINE_NAME-$env:GO_PIPELINE_LABEL-$env:GO_PIPELINE_COUNTER.$env:GO_STAGE_COUNTER"
        $author = ''
        $copyright = "Copyright (c) $((Get-Date).year)"
        $dataDrive = If (Test-Path 'D:') {'D:'} Else {$env:SystemDrive}
        $webservicesPath = "$dataDrive/web"
        $nugetCommand = "$releaseArtifacts/.nuget/NuGet.exe"
        $webName = 'MS'
    $Database = "latform"
    $Connection = "atform?replicaSet=dev_replset1"
        $nugetCommand = "$releaseArtifacts/.nuget/NuGet.exe"
        $createReleaseNuGetPackage = [System.Convert]::ToBoolean($env:ReleasePackage)
    }
    
    Task Default -Depends Deploy
    
    Task Clean -Depends CleanCreatedNuGetPackages
    
    Task CleanAll -Depends Clean
    
    Task CleanCreatedNuGetPackages { Remove-Item $releaseArtifacts/*.nupkg -Force -ErrorAction SilentlyContinue }
    
    Task Deploy -<g class="gr_ gr_150 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" data-gr-id="150" id="150">Depends</g> PublishWeb
    
    Task All -<g class="gr_ gr_151 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" data-gr-id="151" id="151">Depends</g> PublishNuGetPackages, Deploy {}
    
    Task PublishWeb {
    Try
    {
        Invoke-XmlPreprocess "$releaseArtifacts/$webName/Web.Config" $configurationEnvironmentVariables.Keys
    
        Publish-<g class="gr_ gr_149 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="149" id="149">WebApplication</g> `
            "$releaseArtifacts/$webName" `
            "$webservicesPath/$webName/$uniqueDeploymentPath" `
            "$webName.$env:ConfigurationEnvironment" `
            -IdentityType LocalSystem `
            -IdleTimeout ([TimeSpan]::FromDays(1))
    }
    Catch
    {
       
    }
    Finally
    {
           $formatstring = "{0}"
       $fields = $_.ErrorDetails.Message
           $formatstring -f $fields
     
        "This script made a read attempt error is $formatstring" | out-file D:\logs\ExpensesScript.log -append
    "This script made a read attempt error is $fields" | out-file D:\logs\ExpensesScript.log -append
    }
    }
    
    Task CreateNuGetPackages -Depends CleanCreatedNuGetPackages {
        $private:packages = "$releaseArtifacts/NuGetPackage/packages"
    
        $private:nuSpecFile = "$packages/MS.Core/United.EMS.Core.nuspec"
        New-NuGetPackage $nuSpecFile $createReleaseNuGetPackage -NuGetExe $nugetCommand
    
        $private:nuSpecFile = "$packages/MS.Domain/United.EMS.Domain.nuspec"
        New-NuGetPackage $nuSpecFile $createReleaseNuGetPackage -NuGetExe $nugetCommand
    
        $private:nuSpecFile = "$packages/MS.Persistence/United.EMS.Persistence.nuspec"
        New-NuGetPackage $nuSpecFile $createReleaseNuGetPackage -NuGetExe $nugetCommand
    }
    
    Task PublishNuGetPackages -Alias NuGet -Depends CreateNuGetPackages {
        $private:nugetRepository = (Get-Childitem env:TS_NUGET_REPOSITORY).Value
        $private:publishToNuGetRepository = (Split-Path $nugetRepository) -Replace '\\', '/'
        $(dir .\*.nupkg) | ForEach { Publish-NuGetPackage $_ $publishToNuGetRepository }
    }
    
    Task AcceptanceTest -Alias Accept {
        $private:testAssemblies = Get-ChildItem $releaseArtifacts -Filter '*Acceptance.Tests.dll' -Recurse |
            Where { (Test-Path ($_.Directory.FullName + "/xunit*.dll")) } |
            ForEach  {$_.FullName}
    
        $private:xunitCommand = "$releaseArtifacts/packages/xunit.runner.console/tools/xunit.console.exe"
        $private:testResultsDirectory = "$releaseArtifacts/TestResults"
        Invoke-xUnit $testAssemblies @('-notrait', 'Category=Broken') -XUnitCommand $xunitCommand -TestResultsDirectory $testResultsDirectory
    }
    
    FormatTaskName { Param($taskName) Write-Host ((("-"*25) + "[{0}]" + ("-"*$(50-$taskName.Length))) -f $taskName) -ForegroundColor Green }
    
    
    
    


    • Edited by KAPSIIII Wednesday, January 23, 2019 12:41 AM
    Tuesday, January 22, 2019 11:11 PM
  • Last time.  Please post code correctly using the code posting tool provided on the edit bar.

    The code you have posted is unreadable and is filled with HTML characters from your browser.

    Please read the following to understand how to post in a technical forum: How to ask questions in a technical forum

    Also note that we cannot debug scripts that you have found on the Internet. 


    \_(ツ)_/



    • Edited by jrv Tuesday, January 22, 2019 11:21 PM
    Tuesday, January 22, 2019 11:18 PM
  • Done, Please help on this, Thanks.
    Wednesday, January 23, 2019 12:42 AM
  • Thank you.  Now give us the full error message that you are receiving.  Also remember that we are not going to debug a script you have found on the Internet.  For more than a simple answer please contact the author of the script.


    \_(ツ)_/

    Wednesday, January 23, 2019 1:06 AM
  • 15:51:08.724 At D:\GoAgent\pipelines\Deploy.Dev\ReleaseArtifacts\deploy.ps1:94 char:26
    15:51:08.724  +     Invoke-XmlPreprocess "$releaseArtifacts/$webName/Web.Config" $configurationE ...
    15:51:08.725  +                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [<<==>>] Exception: Cannot validate argument on parameter 'private:configFile'. The " Test-Path $_ -PathType Leaf " validation script for the argument with value "D:\GoAgent\pipelines\Deploy.Dev\ReleaseArtifacts/United.ODMS/Web.Config" did not return a result of True. Determine why the validation script failed, and then try the command again. --> The " Test-Path $_ -PathType Leaf " validation script for the argument with value "D:\GoAgent\pipelines\Deploy.Dev\ReleaseArtifacts/United.ODMS/Web.Config" did not return a result of True. Determine why the validation script failed, and then try the command again.

    Wednesday, January 23, 2019 1:15 AM
  • Can you post the PowerShell error and not some log content or an interpretation by another tool?


    \_(ツ)_/

    Wednesday, January 23, 2019 1:18 AM
  • I have only this error,
    
    I have deploy.cmd file in which I have below the line. i go to the path in cmd command tool and run deploy.cmd.
    
    %POWRESHELL% -Command "& '%PACKAGES%\psake\tools\psake.ps1' '%~dp0\deploy.ps1' %*; if ($psake.build_success -eq $false) { exit -1 } else { exit 0 }" ^


    Wednesday, January 23, 2019 1:24 AM
  • If you look at your posted script you will see it is filled with HTML strings.  This is caused by your browser and Grammarly. 

    There is really no easy way to debug this.  You have to run under the debugger and detect what the issue is.

    The main error is "Cannot validateargumentonparameter'private:configFile'"

    You will need to contact the author of this script for assistance since there is no way for us to run the script.

    You have posted the same script twice.  Why?


    \_(ツ)_/

    Wednesday, January 23, 2019 1:25 AM
  • The error code referenced does not exist in your script.

    Sorry but you will have to contact the author for assistance.


    \_(ツ)_/

    Wednesday, January 23, 2019 1:29 AM
  • Its 3 years old script and just i am only the person to support.
    
    How we can debug the psake file? but I am checking every variable of script file by in writing the error in the file by below line
    
    " error is $formatstring" | out-file D:\logs\ExpensesScript.log -append
    
    What is the root cause of the main error? private:configFile
    
    Without debugging, did you face this issue in past?


    Wednesday, January 23, 2019 1:33 AM
  • The script is using a set of third party tools and modules.  There is no way for use to debug this.  Contact the vendor of the "BuildTools" product and see if they can support you.  Without those full libraries there is no way to understand the code. or why it s failing.

    Every step of the script relies on the BuildTools libraries.  The sourcing command for the erro is "Invoke-XmlPreprocess" which does not exist in the code. Either learn how to debug with PowerShell or ask the vendor for assistance.


    \_(ツ)_/

    Wednesday, January 23, 2019 1:40 AM
  • Here is the source and the author of the BuildTools modules:

    https://github.com/nicholasdille/PowerShell-Build


    \_(ツ)_/

    Wednesday, January 23, 2019 1:43 AM
  • Here is the author of PowerShell-BuildTools: https://github.com/nicholasdille?tab=repositories


    \_(ツ)_/

    Wednesday, January 23, 2019 1:50 AM
  • Thanks but I found something,
    
    Actually, web.config file and the folder $webName is not there on the server that's why getting the error in below line 
    
    Invoke-XmlPreprocess "$releaseArtifacts/$webName/Web.Config" $configurationEnvironmentVariables.Keys
    
    But why this folder and config file is not there. before this line following below psake task executed.
    
    Task Default -Depends Deploy
    
    Task Clean -Depends CleanCreatedNuGetPackages
    
    Task CleanAll -Depends Clean
    
    Task CleanCreatedNuGetPackages { Remove-Item $releaseArtifacts/*.nupkg -Force -ErrorAction SilentlyContinue }
    
    Task Deploy -Depends PublishWeb
    
    Task All -Depends PublishNuGetPackages, Deploy {}
    


    Wednesday, January 23, 2019 1:55 AM
  • Again.  No one here is likely to have this system or to have any experience with it.  I looked at the code and it is interesting.  I will eventually look at it closer.  As to how it works … that is now evident from the code  

    It is up to you to learn the "BuildTools" and NuGet systems to figure out what is wrong.  I am not a developer on NuGet so I cannot be of much help.  It is a big project and all opensource.

    In all cases this is probably not a good forum for finding your answer.

    Good luck.


    \_(ツ)_/

    Wednesday, January 23, 2019 2:15 AM