Generating valid .zip files in Azure DevOps - Compressed folder is invalid - azure-devops

I have an Azure DevOps build pipeline. In that pipeline, I have the following tasks:
dotnet build
Path to project(s): ./MyConsoleApp/MyConsoleApp.csproj
Arguments: --configuration Release --output ../content
Archive Files
Root folder or file to archive: ./content
Prepend root folder name to archive paths: unchecked
Archive type: zip
Archive file to create: content.zip
Replace existing archive: checked
AzureBlob File Copy
Source: content.zip
Destination Type: Azure Blob
RM Storage Account: "<mystorageaccount>"
Container Name: "content"
Blob Prefix: MyConsoleApp/content
This build pipeline runs successfully. I can see the .zip file successfully created and in my Azure Storage account. The size looks like an appropriate size for the console app. However, I'm unable to unzip the .zip file.
When I download the .zip file from Azure Storage, I then try to "unzip" it. I do this by right-clicking on the .zip file in File Explorer nd choosing "Extract All...". I click "Extract" and I get an error that says:
The Compressed (zipped) Folder 'C:\Users\user\Downloads\content.zip' is invalid.
I don't understand this. Everything looks correct. What am I doing wrong?

Related

Release Pipeline unpack the zip and replace azure and connect the linux server throught ssh to copy files

I need to unzip the build zip file and replace the variables define in release pipeline by using replace token task in properties file after that i need to deployed in linux server by using ssh copy files task.
Below are the steps I am doing
I created extract file task there i mention Destination folder : $(Build.SourcesDirectory)
After that i created replace token task Root directory given $(Build.SourcesDirectory) from this directory find the properties file and replace the variables
Then I created copy files to over SSH here i gave Source folder $(Build.SourcesDirectory) to Target folder /home/*/-CICD ( deployment folder path in linux server).
Is this a correct apporach? do we have anyother option for this requirment.
please guide me .

Azure build pipeline: build output generates dll json pdb outside the bin folder in artifacts

We are deploying asp.net core application through build pipeline and artifacts it creates have many dll json pdb files outside the bin folder. We want it move it to bin folder and remove unused files. We have tried copy task but its not working.
We are using .Net Core command to publish the project by passing arguments: —configuration $(BuildConfiguration) —output $(build.artifactstagingdirectory)
How do I define copy task to move all the unused and binary files to bin folder.
Thanks.
Azure build pipeline: build output generates dll json pdb outside the bin folder in artifacts
To use the copy task, we should use the predefined variables System.DefaultWorkingDirectory as Source Folder instead of selecting it directly by the Browse Source Folder:
That because the generates files on the agent where we build the pipeline not in the repo.

azure devops: copy file to artifact folder to access in release pipeline

I am creating a build for ios using azure and I want to copy a certificate file to artifact folder created to use in the release pipeline.
I am using a copy task and after the task is done its job, I am not able to find a copied file at the desired artifact folder. there are answers for copy task but not working for my scenario.
or is there any way to access files from the source folder of build pipeline to from release pipeline?
You were using download secure files task to download the cert files. As below described: see here for more information.
Once downloaded, use the name value that is set on the task (or "Reference name" in the classic editor) to reference the path to the secure file on the agent machine. For example, if the task is given the name mySecureFile, its path can be referenced in the pipeline as $(mySecureFile.secureFilePath). Alternatively, downloaded secure files can be found in the directory given by $(Agent.TempDirectory)
The secure files are downloaded to directory $(Agent.TempDirectory) and its path can be referenced by $(mySecureFile.secureFilePath) if you set the reference name to mySecureFile
So that the copy files task of yours need to be configured as below: Set the Source Folder to $(Agent.TempDirectory) and Contents to the name of the secure files. See below example:
You can also set the Contents to $(certFile.secureFilePath) $(provisionFile.secureFilePath) if you set the Reference name of above download secure file tasks to certFile and provisionFile
More conveniently you can use download secure files task directly in release pipeline to download the cert files.
Then the secure files will be available in release pipeline, and can be referenced just like in the build pipeline.

Specify name of ZIP file created by AppVeyor

AFAICT I can tell AppVeyor to wrap an entire folder into a zip file artifact, as in the following example:
artifacts:
- path: logs
name: test logs
type: zip
which will push all the files in the logs subfolder to the logs.zip ZIP file.
I want to give the generated ZIP file a different name. How can I do that?
Issue number 929 in the community support repository suggests that this is currently not supported declaratively. What you can do is rename the artifact in the after_build step as outlined in the issue:
after_build:
- appveyor PushArtifact local-file.zip -FileName remote-file-%appveyor_build_version%.zip
It appears that the name attribute controls the name of the ZIP file as well. So if I want the ZIP file to be named foo.zip, I can write the following in the appveyor.yml:
artifacts:
- path: logs
name: foo
type: zip
And so I've done -- see here and here.

How to add config file that is in .gitIgnore to azure pipeline build?

I have a json config file with connectionStrings and other info that I don't want in the gitHub repository. Is there a way to just add it as a constant static file so that all builds have access to it?
You can add the file to the "Library" then download the file in the build pipeline and use it.
The file will be downloaded to a temp folder in the agent:
$(Agent.WorkFolder)\_temp\filename
During the build you can take the file from there and use him.