azure-devopsdotnet-publish

Azure DevOps publish zip remove hidden folder


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?

Configuration of the publish pipeline


Solution

  • 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