Copying XAP file to ClientBin on the deployment server not working - silverlight

All I am trying to do here is that I have a set of files in a network share folder and I am trying to copy them to the deployment server through a PS script.
The .dll and .pdb files are getting copied as expected to the "bin" folder. But the .xap file is not copied to the "ClientBin" folder.
I also tried placing the .dll file into the same folder. That didn't work either. Deleting from the folder also not working.
Here is a snippet from PS script I am using for the deployment.
try
{
# Copy all of the files from the source location to the deployment directory
Write-Host "DeployService: Deploying new files for ""$serviceWebSiteName""..."
Copy-Item $sourceDirectory"\*.dll" $deploymentDirectory
Copy-Item $sourceDirectory"\*.exe" $deploymentDirectory
Copy-Item $sourceDirectory"\*.pdb" $deploymentDirectory
Copy-Item $sourceDirectory"\*.xap" $deploymentDirectory2
Write-Host "DeployService: Deploying new files for ""$serviceWebSiteName""...complete"
}
catch
{
Write-Host $_.Exception.ToString() -foregroundcolor red
}
Verified the permissions for the user. The users have same permission on both "bin" folder and the "ClientBin". Not sure how it works for bin and does not for clientbin.
Will greatly appreciate any help or input here
Thanks

Related

How to upload react build folder to my remote server?

I'm trying to deploy my react build folder to my server. I'm using index.html and static that configured in my settings.py file to do that. (https://create-react-app.dev/docs/deployment/)
Since my backend is running on Ubuntu, I can't just copy from my Windows side and paste it. For now, I uploaded my build folder to my Google Drive and I download it on Ubuntu. But I still can't just copy and paste it on my PyCharm IDE, I can only copy the content in each file and then create a new file ony my server and paste the content to the file. This is just so time-consuming.
Is there any better way to do this?
you can use scp to upload the floder to remote
This link may help you:
https://linuxhandbook.com/transfer-files-ssh/
use scp command
# in dest folder:
scp username#remove_address:/path/for/deploy ./

WinSCP - Download file from SFTP server to network location, then delete

I need to write a WinSCP script or batch file that will download the contents of a remote SFTP folder, delete contents and then upload to a mapped network folder. I know how to write the login part of the script. But I am confused as to what the specific command line should look like. From what I've read the command script to download and delete the file is something like this:
get -delete -transfer=binary *
The part that I'm not getting is the upload to the network folder command. I understand put is the WinSCP upload command operator. But how do I use it in conjunction with the network folder location files should be uploaded to? Also, can this be scripted out in a batch file or do the batch file and script need to be written separately? Thanks!
An "upload" to a mapped network folder is not a job for WinSCP. A mapped network folder behaves as a local drive. A plain Windows copy command will do. So first do your WinSCP download and then copy (it's not really called an upload) the files to the network drive.
winscp /ini=nul /command ^
"open sftp://user:password#example.com/" ^
"get -delete /sftp/path/* c:\local\drive\path\" ^
"exit"
copy c:\local\drive\path\* n:\mapped\network\drive\path\
Though, if you do not need the files locally, you can have WinSCP download the files from the SFTP folder directly to the mapped network drive:
winscp /ini=nul /command ^
"open sftp://user:password#example.com/" ^
"get -delete /sftp/path/* n:\mapped\network\drive\path\" ^
"exit"

How do I zip a SQL Server backup file using Powershell and save in the same directory?

I am trying to zip up a SQL Server backup file and save it in the same directory using PowerShell. The only way it works for me is if I move it to a temp folder then zip it up and move it back to the original folder. But I don't want to move it. I just want to keep it in the existing folder and ignore all other files in the folder. The zip file name should be the same name as the backup file with extension as .zip and it doesn't need to be in a folder.
Here is my code (which I would like to change)
#Backup SQL database
Backup-SqlDatabase -Database Mydbname -ServerInstance MyServerName- BackupSetName "Mydbname-Full Database Backup" -DatabaseFile Mydbname.bak -ExpirationDate 0 -Initialize
#Move backup to temp location and Zip the folder
$temppath = "C:\Temp\Bkup"
$sourcepath = "C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup\Mydbname.bak"
$destpath = "C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup\"
Move-Item -Path $sourcepath -Destination $temppath
Compress-Archive -Path $temppath -DestinationPath\Mydbname.bak.zip
Is there a way to streamline this code so that it doesn't create a new folder?
Note: If I run the script twice, it will fail the second time around because I still have the moved file in the temp folder. Is there a way to delete the file from the temp location after moving it back to the original folder. (I am new to PowerShell.)
Since your source is one file, try this. Compress archive can take a source as a single file. I commented out 2 of the lines.
$sourcepath = "C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup\Mydbname.bak"
$destpath = "C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup\"
Compress-Archive -Path $sourcepath -DestinationPath\Mydbname.bak.zip

using unzip within PowerShell

Every night we need to zip certain files contained in a folder. I then need to make sure that all the files that should have been zipped are in the zip file.
I have created a piece of code that work perfectly on my PC but when I move the code to the live server I get the following error:-
The term 'unzip' is not recognized as the name of a cmdlet'
I have installed dot.net 4.5 & also the PowerShell Community Extensions 3.1
Here is my code that creates an array of file names:-
$UnZip_Test = unzip -t $ZipFile
$zip_contents = $UnZip_Test | ? { $_ -match "^\s*testing:\s*(.*?)\s+OK\s*$"} | % { $matches[1] }
unzip is not the cmd-let Community Extensions uses. If you had correctly installed the PCE 3.1 you should be able to use Expand-Archive cmdlet.
expand-archive -format zip -path $ZipFile
unzip is not a PowerShell built-in command. You need to provide an unzip.exe in one of the folders in the $env:PATH on the production server, or define a function/cmdlet or alias that does The Right Thing™.
I use this in my powershell scripts, granted it's not powershell but requires java to be installed.
jar xf ./path/to/archive.zip
In my case, knowing java is on a server is a lot easier than downloading some community extension all over the place

bat file - delete directory contents except specific file and specific subfolder

I have a directory 'help' where a web application is deployed. It contains a number of files at the root level and a number of sub folders.
I'd like to run a bat file (from outside the directory) which deletes everything within the directory except for the web.config file and a folder called 'log'.
Is this possible?
Not directly, but what you can do is copy the file and folder in a different location, delete the entire content of the folder, then restore the file and folder.

Resources