Specifiy files in publish profile to be removed?2019 Community Moderator ElectionDeploying an existing package using publish profilesHow to configure TFS Build: MSBuild Arguments: Publish Profile: File SystemPublish appsettings.production.json onto azurePublish not getting connection string from appsettings.production.jsonDifferent PrepublishScript for different publish profilesASP.NET web app (.NET framework) webpack generated files during publish are not copied to target locationHow to update appsettings.json based on publish profile using .NET Core?Loading appsettings.<>.json file when hosted via Windows ServiceHow do environment variables and appSettings file(s) get used during publish?How to set the environment var during publish

Is this Paypal Github SDK reference really a dangerous site?

What is the oldest European royal house?

After Brexit, will the EU recognize British passports that are valid for more than ten years?

How to install "rounded" brake pads

Vector-transposing function

How does learning spells work when leveling a multiclass character?

Short story about cities being connected by a conveyor belt

Is the differential, dp, exact or not?

What exactly is the meaning of "fine wine"?

Should we avoid writing fiction about historical events without extensive research?

Who has more? Ireland or Iceland?

What would be the most expensive material to an intergalactic society?

Did Amazon pay $0 in taxes last year?

What is better: yes / no radio, or simple checkbox?

Issue with units for a rocket nozzle throat area problem

Why does this boat have a landing pad? (SpaceX's GO Searcher) Any plans for propulsive capsule landings?

The (Easy) Road to Code

A running toilet that stops itself

Having the player face themselves after the mid-game

Short SF story. Females use stingers to implant eggs in yearfathers

Is divide-by-zero a security vulnerability?

How do you use environments that have the same name within a single latex document?

Why do we call complex numbers “numbers” but we don’t consider 2-vectors numbers?

Does an unused member variable take up memory?



Specifiy files in publish profile to be removed?



2019 Community Moderator ElectionDeploying an existing package using publish profilesHow to configure TFS Build: MSBuild Arguments: Publish Profile: File SystemPublish appsettings.production.json onto azurePublish not getting connection string from appsettings.production.jsonDifferent PrepublishScript for different publish profilesASP.NET web app (.NET framework) webpack generated files during publish are not copied to target locationHow to update appsettings.json based on publish profile using .NET Core?Loading appsettings.<>.json file when hosted via Windows ServiceHow do environment variables and appSettings file(s) get used during publish?How to set the environment var during publish










0















I have 3 different settings files being used with a .NET Core 2.2 app

appsettings.json

appsettings.Development.json

appsettings.Test.json



Im using a publish profile that targets a specific build configuration (eg. Test), and in my publish profile, I added this to attempt to remove the appsettings files I DONT want deployed. No sense in deploying production settings to a dev server...



 <PropertyGroup>
<ExcludeFilesFromDeployment>appsettings.json</ExcludeFilesFromDeployment>
<ExcludeFilesFromDeployment>appsettings.Development.json</ExcludeFilesFromDeployment>
</PropertyGroup>


However, when I publish, since in Visual Studio, all 3 files are present. How can I specify those other 2 files get removed on publish ?



I also tried putting this in my csproj file, but all 3 files end up being published



 <ItemGroup>
<None Update="appsettings.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Test' "/>
<None Update="appsettings.Development.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Test' "/>

<None Update="appsettings.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Release' "/>
<None Update="appsettings.Test.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Release' "/>

</ItemGroup>









share|improve this question
























  • Build configuration has no bearing on ASP.NET Core apps. Since there's nothing like config transforms and such going on, the same published app code can be put in any environment. What ultimately controls which environment-specific configs get load in is the value of the ASPNETCORE_ENVIRONMENT variable, not how you published. That is why publishing includes all the files; there's no mechanism to know in advance which are relevant or not.

    – Chris Pratt
    2 days ago











  • In practice this is hardly a problem. No secret information should be going into these JSON files anyways, so who cares if appsettings.Production.json exists on your dev server?

    – Chris Pratt
    2 days ago















0















I have 3 different settings files being used with a .NET Core 2.2 app

appsettings.json

appsettings.Development.json

appsettings.Test.json



Im using a publish profile that targets a specific build configuration (eg. Test), and in my publish profile, I added this to attempt to remove the appsettings files I DONT want deployed. No sense in deploying production settings to a dev server...



 <PropertyGroup>
<ExcludeFilesFromDeployment>appsettings.json</ExcludeFilesFromDeployment>
<ExcludeFilesFromDeployment>appsettings.Development.json</ExcludeFilesFromDeployment>
</PropertyGroup>


However, when I publish, since in Visual Studio, all 3 files are present. How can I specify those other 2 files get removed on publish ?



I also tried putting this in my csproj file, but all 3 files end up being published



 <ItemGroup>
<None Update="appsettings.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Test' "/>
<None Update="appsettings.Development.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Test' "/>

<None Update="appsettings.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Release' "/>
<None Update="appsettings.Test.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Release' "/>

</ItemGroup>









share|improve this question
























  • Build configuration has no bearing on ASP.NET Core apps. Since there's nothing like config transforms and such going on, the same published app code can be put in any environment. What ultimately controls which environment-specific configs get load in is the value of the ASPNETCORE_ENVIRONMENT variable, not how you published. That is why publishing includes all the files; there's no mechanism to know in advance which are relevant or not.

    – Chris Pratt
    2 days ago











  • In practice this is hardly a problem. No secret information should be going into these JSON files anyways, so who cares if appsettings.Production.json exists on your dev server?

    – Chris Pratt
    2 days ago













0












0








0








I have 3 different settings files being used with a .NET Core 2.2 app

appsettings.json

appsettings.Development.json

appsettings.Test.json



Im using a publish profile that targets a specific build configuration (eg. Test), and in my publish profile, I added this to attempt to remove the appsettings files I DONT want deployed. No sense in deploying production settings to a dev server...



 <PropertyGroup>
<ExcludeFilesFromDeployment>appsettings.json</ExcludeFilesFromDeployment>
<ExcludeFilesFromDeployment>appsettings.Development.json</ExcludeFilesFromDeployment>
</PropertyGroup>


However, when I publish, since in Visual Studio, all 3 files are present. How can I specify those other 2 files get removed on publish ?



I also tried putting this in my csproj file, but all 3 files end up being published



 <ItemGroup>
<None Update="appsettings.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Test' "/>
<None Update="appsettings.Development.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Test' "/>

<None Update="appsettings.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Release' "/>
<None Update="appsettings.Test.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Release' "/>

</ItemGroup>









share|improve this question
















I have 3 different settings files being used with a .NET Core 2.2 app

appsettings.json

appsettings.Development.json

appsettings.Test.json



Im using a publish profile that targets a specific build configuration (eg. Test), and in my publish profile, I added this to attempt to remove the appsettings files I DONT want deployed. No sense in deploying production settings to a dev server...



 <PropertyGroup>
<ExcludeFilesFromDeployment>appsettings.json</ExcludeFilesFromDeployment>
<ExcludeFilesFromDeployment>appsettings.Development.json</ExcludeFilesFromDeployment>
</PropertyGroup>


However, when I publish, since in Visual Studio, all 3 files are present. How can I specify those other 2 files get removed on publish ?



I also tried putting this in my csproj file, but all 3 files end up being published



 <ItemGroup>
<None Update="appsettings.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Test' "/>
<None Update="appsettings.Development.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Test' "/>

<None Update="appsettings.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Release' "/>
<None Update="appsettings.Test.json" CopyToPublishDirectory="Never" Condition=" '$(Configuration)' == 'Release' "/>

</ItemGroup>






visual-studio asp.net-core msbuild csproj






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









Lance Li-MSFT

2666




2666










asked 2 days ago









bitshiftbitshift

1,10831230




1,10831230












  • Build configuration has no bearing on ASP.NET Core apps. Since there's nothing like config transforms and such going on, the same published app code can be put in any environment. What ultimately controls which environment-specific configs get load in is the value of the ASPNETCORE_ENVIRONMENT variable, not how you published. That is why publishing includes all the files; there's no mechanism to know in advance which are relevant or not.

    – Chris Pratt
    2 days ago











  • In practice this is hardly a problem. No secret information should be going into these JSON files anyways, so who cares if appsettings.Production.json exists on your dev server?

    – Chris Pratt
    2 days ago

















  • Build configuration has no bearing on ASP.NET Core apps. Since there's nothing like config transforms and such going on, the same published app code can be put in any environment. What ultimately controls which environment-specific configs get load in is the value of the ASPNETCORE_ENVIRONMENT variable, not how you published. That is why publishing includes all the files; there's no mechanism to know in advance which are relevant or not.

    – Chris Pratt
    2 days ago











  • In practice this is hardly a problem. No secret information should be going into these JSON files anyways, so who cares if appsettings.Production.json exists on your dev server?

    – Chris Pratt
    2 days ago
















Build configuration has no bearing on ASP.NET Core apps. Since there's nothing like config transforms and such going on, the same published app code can be put in any environment. What ultimately controls which environment-specific configs get load in is the value of the ASPNETCORE_ENVIRONMENT variable, not how you published. That is why publishing includes all the files; there's no mechanism to know in advance which are relevant or not.

– Chris Pratt
2 days ago





Build configuration has no bearing on ASP.NET Core apps. Since there's nothing like config transforms and such going on, the same published app code can be put in any environment. What ultimately controls which environment-specific configs get load in is the value of the ASPNETCORE_ENVIRONMENT variable, not how you published. That is why publishing includes all the files; there's no mechanism to know in advance which are relevant or not.

– Chris Pratt
2 days ago













In practice this is hardly a problem. No secret information should be going into these JSON files anyways, so who cares if appsettings.Production.json exists on your dev server?

– Chris Pratt
2 days ago





In practice this is hardly a problem. No secret information should be going into these JSON files anyways, so who cares if appsettings.Production.json exists on your dev server?

– Chris Pratt
2 days ago












2 Answers
2






active

oldest

votes


















0














Not 100% sure on this one, but just a thought, have you tried setting those to only copy when it matches the build configuration expected, e.g.



 <ItemGroup>
<None Update="appsettings.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Production' "/>
<None Update="appsettings.Development.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Development' "/>
<None Update="appsettings.Test.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Test' "/>
</ItemGroup>


Also please check your .net core version is not affected by https://github.com/dotnet/sdk/issues/881






share|improve this answer






























    0














    Not sure, but put this into your .csproj file to check if it helps.It works in vs2017, .net core on my side.



    <ItemGroup Condition="'$(Configuration)' == 'Test'">
    <Content Remove="appsettings.Development.json" />
    <None Include="appsettings.Development.json" />
    <Content Remove="appsettings.json" />
    <None Include="appsettings.json" />
    </ItemGroup>

    <ItemGroup Condition="'$(Configuration)'=='Release'">
    <Content Remove="appsettings.Test.json" />
    <None Include="appsettings.Test.json" />
    <Content Remove="appsettings.json" />
    <None Include="appsettings.json" />
    </ItemGroup>





    share|improve this answer






















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55028065%2fspecifiy-files-in-publish-profile-to-be-removed%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Not 100% sure on this one, but just a thought, have you tried setting those to only copy when it matches the build configuration expected, e.g.



       <ItemGroup>
      <None Update="appsettings.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Production' "/>
      <None Update="appsettings.Development.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Development' "/>
      <None Update="appsettings.Test.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Test' "/>
      </ItemGroup>


      Also please check your .net core version is not affected by https://github.com/dotnet/sdk/issues/881






      share|improve this answer



























        0














        Not 100% sure on this one, but just a thought, have you tried setting those to only copy when it matches the build configuration expected, e.g.



         <ItemGroup>
        <None Update="appsettings.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Production' "/>
        <None Update="appsettings.Development.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Development' "/>
        <None Update="appsettings.Test.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Test' "/>
        </ItemGroup>


        Also please check your .net core version is not affected by https://github.com/dotnet/sdk/issues/881






        share|improve this answer

























          0












          0








          0







          Not 100% sure on this one, but just a thought, have you tried setting those to only copy when it matches the build configuration expected, e.g.



           <ItemGroup>
          <None Update="appsettings.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Production' "/>
          <None Update="appsettings.Development.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Development' "/>
          <None Update="appsettings.Test.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Test' "/>
          </ItemGroup>


          Also please check your .net core version is not affected by https://github.com/dotnet/sdk/issues/881






          share|improve this answer













          Not 100% sure on this one, but just a thought, have you tried setting those to only copy when it matches the build configuration expected, e.g.



           <ItemGroup>
          <None Update="appsettings.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Production' "/>
          <None Update="appsettings.Development.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Development' "/>
          <None Update="appsettings.Test.json" CopyToPublishDirectory="PreserveNewest" Condition=" '$(Configuration)' == 'Test' "/>
          </ItemGroup>


          Also please check your .net core version is not affected by https://github.com/dotnet/sdk/issues/881







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          Pedro Maia CostaPedro Maia Costa

          1,86121321




          1,86121321























              0














              Not sure, but put this into your .csproj file to check if it helps.It works in vs2017, .net core on my side.



              <ItemGroup Condition="'$(Configuration)' == 'Test'">
              <Content Remove="appsettings.Development.json" />
              <None Include="appsettings.Development.json" />
              <Content Remove="appsettings.json" />
              <None Include="appsettings.json" />
              </ItemGroup>

              <ItemGroup Condition="'$(Configuration)'=='Release'">
              <Content Remove="appsettings.Test.json" />
              <None Include="appsettings.Test.json" />
              <Content Remove="appsettings.json" />
              <None Include="appsettings.json" />
              </ItemGroup>





              share|improve this answer



























                0














                Not sure, but put this into your .csproj file to check if it helps.It works in vs2017, .net core on my side.



                <ItemGroup Condition="'$(Configuration)' == 'Test'">
                <Content Remove="appsettings.Development.json" />
                <None Include="appsettings.Development.json" />
                <Content Remove="appsettings.json" />
                <None Include="appsettings.json" />
                </ItemGroup>

                <ItemGroup Condition="'$(Configuration)'=='Release'">
                <Content Remove="appsettings.Test.json" />
                <None Include="appsettings.Test.json" />
                <Content Remove="appsettings.json" />
                <None Include="appsettings.json" />
                </ItemGroup>





                share|improve this answer

























                  0












                  0








                  0







                  Not sure, but put this into your .csproj file to check if it helps.It works in vs2017, .net core on my side.



                  <ItemGroup Condition="'$(Configuration)' == 'Test'">
                  <Content Remove="appsettings.Development.json" />
                  <None Include="appsettings.Development.json" />
                  <Content Remove="appsettings.json" />
                  <None Include="appsettings.json" />
                  </ItemGroup>

                  <ItemGroup Condition="'$(Configuration)'=='Release'">
                  <Content Remove="appsettings.Test.json" />
                  <None Include="appsettings.Test.json" />
                  <Content Remove="appsettings.json" />
                  <None Include="appsettings.json" />
                  </ItemGroup>





                  share|improve this answer













                  Not sure, but put this into your .csproj file to check if it helps.It works in vs2017, .net core on my side.



                  <ItemGroup Condition="'$(Configuration)' == 'Test'">
                  <Content Remove="appsettings.Development.json" />
                  <None Include="appsettings.Development.json" />
                  <Content Remove="appsettings.json" />
                  <None Include="appsettings.json" />
                  </ItemGroup>

                  <ItemGroup Condition="'$(Configuration)'=='Release'">
                  <Content Remove="appsettings.Test.json" />
                  <None Include="appsettings.Test.json" />
                  <Content Remove="appsettings.json" />
                  <None Include="appsettings.json" />
                  </ItemGroup>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  Lance Li-MSFTLance Li-MSFT

                  2666




                  2666



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55028065%2fspecifiy-files-in-publish-profile-to-be-removed%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                      2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

                      Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme