Azure DevOps publish zip remove hidden folder - azure-devops

I'm configuring an azure devops pipeline and want to zip the package for the publish.
When I choose to zip, a directory that I have in the code (/wwwroot/.well-known) is not included in the zip.
Is there an option that exclude hidden folders?

I don't think the Azure DevOps task for running .NET commands has the option to include/exclude files while publishing. You can however configure that in your .csproj file.
Please refer the documentation on CopyToPublishDirectory.
I have tried the following and I was able to include a directory called .well-known which was created in my wwwroot folder
$ dotnet new webapp -o aspnetcoreapp
$ cd aspnetcoreapp
$ mkdir wwwroot/.well-known && touch wwwroot/.well-known/some-file
Add this to your .csproj file to include the .well-known directory
<ItemGroup>
<Content Include="wwwroot/.well-known/*" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
</ItemGroup>
Publish your project
$ dotnet publish
$ ls -la bin/Debug/net6.0/publish/wwwroot

Related

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> Run Test Plan: Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException

Added a Run tests task to a pipeline. Tests pass, but the log shows the below error:
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Unable to find **\obj\release\netcoreapp2.2\myProject.deps.json. Make sure test project has a nuget reference of package "Microsoft.NET.Test.Sdk".
The project does have the nuget package for the Test.Sdk.
What do I miss here? Thank you.
The error said myProject.deps.json is missing from folder "\obj\release..". This folder contains the output files of dotnet build,which doesnot have file myProject.deps.json. You might need to point the vstest search folder to the published folder of dotnet publish task.
You can add an output arguments (-o $(build.artifactstagingdirectory)) for your dotnet publish task to specifically publish to a folder.
For below example the output files are published to $(build.artifactstagingdirectory) which has file myProject.deps.json.
Then in your vstest task, you can specify the test search folder to $(build.artifactstagingdirectory)

Dynamic Bin folders hard to copy bin folder to artifact location Azure DevOps

I have a problem with my CI in Azure DevOps.
I need to have a generic PowerShell script run in each CI that copy files from the bin folder and put them to artifact(a) folder with each project folder name.
But bin path are dynamic e.g.
$projectBinDirectory\bin\release\net471\win-x64
$projectBinDirectory\bin\release\net471
$projectBinDirectory\bin\Release\netcoreapp2.1\win-x64
$projectBinDirectory\bin\Release\netcoreapp2.2\win-x64
$projectBinDirectory\bin\Release\netcoreapp2.1
in the future, if someone creates netcore 2.2 or something else how to configure publish path dynamically as I want to copy main project files
e.g.
copy from
bin\release\netcoreapp2.1\win-x64 all project *.dlls,*configs etc files
to
artifact\Projectname\ all project files
the issue
cannot figure out after bin\release\ path to reach to project files
I need to figure out what is the path dynamically after bin\release...\projectFiles
this argument fixed my issue
-c Release -o ./bin/$(BuildConfiguration)/publishNew:

Exclude/Skip files in VSTS Build and release

We are in process of creating architecture for VSTS CI/CD to deploy our web app to our Azure App Services.
We want to exclude the web.config while deploying it to the Azure server as we are directly modifying the web.config on the different environment.
CI Tasks looks like this:
CI Taks
CD Task:
Deploy Azure App Service
I am aware of other ways of updating the web.config https://learn.microsoft.com/en-us/vsts/build-release/tasks/transforms-variable-substitution, but in our case we want to skip the web.config file.
I couldn’t find the option to skip file in during release in VSTS as mentioned in this thread
How do I exclude the .cs files within an artifact from a vs-team-services CI build?
Is there a way to exclude certain files while building and deploying the release?
Added -skip:objectName=filePath,absolutePath=web\.config in additional arguments. This skips updating the web.config file during deployment.
You can exclude the web.config before publishing artifacts in your build definition: copy the web packages files to a directory (such as $(build.binariesdirectory)), then copy the files exclude web.config to another folder (such as $(Build.ArtifactStagingDirectory)/package), and zip the files under $(Build.ArtifactStagingDirectory)/package. And finally publish the zip file as build artifacts.
Details changes in the build definition as below:
Change the MSbuild arguments as /p:OutDir="$(build.binariesdirectory)\\" in Visual Studio Build task.
Add a Copy Files task after Visual Studio Build task. Settings for this task as below:
Add Archive Files task after Copy Files task. And settings as below:
Change the Publish Artifacts task as below:
Now the build artifacts are exclude web.config file.
Additional arguments
-skip:objectName=filePath,absolutePath=\\Configuration\\AppSettings\\Base.config
you can add
-skip:objectName=filePath,absolutePath='.*\PackageTmp\Web.config$'
in Additional Arguments in "Deploy IIS WebSite/App" deployment VSTS task, this will not deploy your root web.config file.

Publising nuget package with Powershell scripts - scripts are not packaged

I am using Visual Studio Team Services to package a folder and pr documentation I have added a content folder, also tried with contentFiles folder, that contains another folder and then my powershell script. The package is created, but the content folder is not packaged.
Structure is like /content/ReleaseScripts/MyScript.ps1
If you package project file directly, you need to change that file’s Build Action to Content. (Right click the file in VS > Properties >Change Build Action to Content)
If you just create .nuspec file in a folder (no project file, such as .csproj) and pack this .nuspec file, you can refer to these steps:
Add Nuget.exe tool to source control and map to build agent (same folder level (content folder) that you need to package) or add it to the environment variable (path) of build agent service account.
Add Command Line task (Tool: nugget.exe; Arguments: spec; Working folder:[same level path that you need to package, such as the folder path that contains content folder]
Add NuGet Packager task (Path to csproj or nuspec files to pack: **\*.nuspec)