Reputation: 101
we are deploying Azure WebApps via Octopus. We could set octopus to remove all files (except App_Data) before a publish, but we only want to remove certain files. We can trigger powershell scripts via Octopus so maybe we can use powershell to remove file/folders in the webapp.
Are there Powershell Cmdlets to remove certain files or folders on an Azure webapp?
Upvotes: 0
Views: 472
Reputation: 253
Open your file properties which will you exclude in your solution. Change for each file properties to Not content/no action/ dont copy to output.. like this.
Or you should open your project properties and exclude your files from post build step.
Upvotes: 0
Reputation: 250812
Yes, you can do this with PowerShell. The example below checks the file exists and then removes them.
If (Test-Path $FileName){
Remove-Item $FileName
}
And you can use Octopus Variables within your PowerShell script if you need to. For example, a variable in your project named $FileName
would satisfy the sample above.
You can also get the path Octopus has placed the application in:
$Path = $OctopusParameters['Octopus.Action[Step Name].Output.Package.InstallationDirectoryPath']
Upvotes: 1