Search code examples
c#asp.netmsbuildcsproj

Publish ASP.NET app without certain folders


I have a csproj with some folders with code from different clients. When i publish my app i get something like this:

  • Client1Folder
  • Client2Folder
  • Client3Folder
  • Client3Folder2
  • SomeCommonFilesAndFolders
  • SomeFileThatNeedToBeDeleted

So in order to give it to client 3 i have to delete some files and end like this:

  • Client3Folder
  • Client3Folder2
  • SomeCommonFilesAndFolders

Whats the best way to aproach this? I searched something like project configuration like "Debug" and "Release" but i dont know if thats ok and how to specify the folders.


Solution

  • You can add a configuration per client and then in your csproj do something like this:

    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Client3|AnyCPU'">
        <OutputPath>bin\Client3\</OutputPath>
        <ExcludeFilesFromDeployment>SomeFileThatNeedToBeDeleted</ExcludeFilesFromDeployment>
        <ExcludeFoldersFromDeployment>Client1Folder;Client2Folder</ExcludeFoldersFromDeployment>
    </PropertyGroup>
    

    Publish

    dotnet publish -c Client3