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
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
add a comment |
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
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 theASPNETCORE_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 ifappsettings.Production.json
exists on your dev server?
– Chris Pratt
2 days ago
add a comment |
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
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
visual-studio asp.net-core msbuild csproj
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 theASPNETCORE_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 ifappsettings.Production.json
exists on your dev server?
– Chris Pratt
2 days ago
add a comment |
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 theASPNETCORE_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 ifappsettings.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
add a comment |
2 Answers
2
active
oldest
votes
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
add a comment |
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>
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered 2 days ago
Pedro Maia CostaPedro Maia Costa
1,86121321
1,86121321
add a comment |
add a comment |
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>
add a comment |
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>
add a comment |
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>
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>
answered yesterday
Lance Li-MSFTLance Li-MSFT
2666
2666
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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