Transforming configuration files











up vote
0
down vote

favorite












I'm building a Nuget package that acts as a logger for other applications. One of the features it needs to house different config properties (slack webhook urls, application name, and etc...) and the developer can edit these values within the app.config or whatever is the config file.



One of the approaches I've used was creating transform files suggested by the documentation Microsoft provided here



However, when testing the nuget package on a console application with both .Net Framework and Core, the config files do not have the settings the transform files have from the nuget package. After some research, it turns out if the project uses PackageReference it cannot make changes to the configuration file.




For projects using packages.config, NuGet supports the ability to make transformations to source code and configuration files at package install and uninstall times. Only Source code transformations are applied when a package is installed in a project using PackageReference.




The last solution I tried was from this SO question here from one of the comments. However, still not seeing the change.



Right now, I'm outputting a config file after the build to the application's root folder. Then, the nuget package pulls the config properties into a class which can be shared among the different loggers.



Here is the nuspec file:



<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>POS_LoggingModule</id>
<version>1.0.13</version>
<authors>...</authors>
<owners>...</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Simple library to post logging to a Slack channel.</description>
<tags>Slack</tags>
<dependencies>
<group targetFramework=".NETStandard2.0">
<dependency id="Microsoft.Extensions.Configuration" version="2.1.1" exclude="Build,Analyzers" />
<dependency id="Newtonsoft.Json" version="11.0.2" exclude="Build,Analyzers" />
<dependency id="System.Diagnostics.EventLog" version="4.5.0" exclude="Build,Analyzers" />
</group>
</dependencies>
<contentFiles>
<files include="any/netstandard2.0/contentFiles/logging.config" buildAction="Content" />
</contentFiles>
</metadata>
<files>
<file src="binDebugnetstandard2.0POS_LoggingModule.dll" target="libnetstandard2.0POS_LoggingModule.dll" />
<file src="contentFileslogging.config" target="contentcontentFileslogging.config" />
<file src="contentFileslogging.config" target="contentFilesanynetstandard2.0contentFileslogging.config" />
</files>
</package>


The nuget package uses .Net Core 2.1, and.Net Framework 4.6.1. I've been advised by a senior dev to change it to .Net Standard.



Thanks, and I am looking forward to everyone's feedback!










share|improve this question









New contributor




DanStockham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Hi there! Your question is too broad. Here, on stackoverflow, we dealing with coding issues, so if you have a problem with your code (exceptions, unpredictable behavior, etc.) - edit your question or ask another one. You may also find this link useful: stackoverflow.com/help/how-to-ask
    – JohnB
    Nov 5 at 5:56










  • Since you are using .NET Core, why not integrate with their Microsoft.Extensions.Configuration stack? App.config usage is possible again in recent versions but not really used. .NET Standard libraries for example can't rely on the target platform even supporting app.config
    – Martin Ullrich
    Nov 5 at 7:07










  • @johnB Could you elaborate more as to why the question is too broad?
    – DanStockham
    Nov 5 at 14:43















up vote
0
down vote

favorite












I'm building a Nuget package that acts as a logger for other applications. One of the features it needs to house different config properties (slack webhook urls, application name, and etc...) and the developer can edit these values within the app.config or whatever is the config file.



One of the approaches I've used was creating transform files suggested by the documentation Microsoft provided here



However, when testing the nuget package on a console application with both .Net Framework and Core, the config files do not have the settings the transform files have from the nuget package. After some research, it turns out if the project uses PackageReference it cannot make changes to the configuration file.




For projects using packages.config, NuGet supports the ability to make transformations to source code and configuration files at package install and uninstall times. Only Source code transformations are applied when a package is installed in a project using PackageReference.




The last solution I tried was from this SO question here from one of the comments. However, still not seeing the change.



Right now, I'm outputting a config file after the build to the application's root folder. Then, the nuget package pulls the config properties into a class which can be shared among the different loggers.



Here is the nuspec file:



<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>POS_LoggingModule</id>
<version>1.0.13</version>
<authors>...</authors>
<owners>...</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Simple library to post logging to a Slack channel.</description>
<tags>Slack</tags>
<dependencies>
<group targetFramework=".NETStandard2.0">
<dependency id="Microsoft.Extensions.Configuration" version="2.1.1" exclude="Build,Analyzers" />
<dependency id="Newtonsoft.Json" version="11.0.2" exclude="Build,Analyzers" />
<dependency id="System.Diagnostics.EventLog" version="4.5.0" exclude="Build,Analyzers" />
</group>
</dependencies>
<contentFiles>
<files include="any/netstandard2.0/contentFiles/logging.config" buildAction="Content" />
</contentFiles>
</metadata>
<files>
<file src="binDebugnetstandard2.0POS_LoggingModule.dll" target="libnetstandard2.0POS_LoggingModule.dll" />
<file src="contentFileslogging.config" target="contentcontentFileslogging.config" />
<file src="contentFileslogging.config" target="contentFilesanynetstandard2.0contentFileslogging.config" />
</files>
</package>


The nuget package uses .Net Core 2.1, and.Net Framework 4.6.1. I've been advised by a senior dev to change it to .Net Standard.



Thanks, and I am looking forward to everyone's feedback!










share|improve this question









New contributor




DanStockham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Hi there! Your question is too broad. Here, on stackoverflow, we dealing with coding issues, so if you have a problem with your code (exceptions, unpredictable behavior, etc.) - edit your question or ask another one. You may also find this link useful: stackoverflow.com/help/how-to-ask
    – JohnB
    Nov 5 at 5:56










  • Since you are using .NET Core, why not integrate with their Microsoft.Extensions.Configuration stack? App.config usage is possible again in recent versions but not really used. .NET Standard libraries for example can't rely on the target platform even supporting app.config
    – Martin Ullrich
    Nov 5 at 7:07










  • @johnB Could you elaborate more as to why the question is too broad?
    – DanStockham
    Nov 5 at 14:43













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm building a Nuget package that acts as a logger for other applications. One of the features it needs to house different config properties (slack webhook urls, application name, and etc...) and the developer can edit these values within the app.config or whatever is the config file.



One of the approaches I've used was creating transform files suggested by the documentation Microsoft provided here



However, when testing the nuget package on a console application with both .Net Framework and Core, the config files do not have the settings the transform files have from the nuget package. After some research, it turns out if the project uses PackageReference it cannot make changes to the configuration file.




For projects using packages.config, NuGet supports the ability to make transformations to source code and configuration files at package install and uninstall times. Only Source code transformations are applied when a package is installed in a project using PackageReference.




The last solution I tried was from this SO question here from one of the comments. However, still not seeing the change.



Right now, I'm outputting a config file after the build to the application's root folder. Then, the nuget package pulls the config properties into a class which can be shared among the different loggers.



Here is the nuspec file:



<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>POS_LoggingModule</id>
<version>1.0.13</version>
<authors>...</authors>
<owners>...</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Simple library to post logging to a Slack channel.</description>
<tags>Slack</tags>
<dependencies>
<group targetFramework=".NETStandard2.0">
<dependency id="Microsoft.Extensions.Configuration" version="2.1.1" exclude="Build,Analyzers" />
<dependency id="Newtonsoft.Json" version="11.0.2" exclude="Build,Analyzers" />
<dependency id="System.Diagnostics.EventLog" version="4.5.0" exclude="Build,Analyzers" />
</group>
</dependencies>
<contentFiles>
<files include="any/netstandard2.0/contentFiles/logging.config" buildAction="Content" />
</contentFiles>
</metadata>
<files>
<file src="binDebugnetstandard2.0POS_LoggingModule.dll" target="libnetstandard2.0POS_LoggingModule.dll" />
<file src="contentFileslogging.config" target="contentcontentFileslogging.config" />
<file src="contentFileslogging.config" target="contentFilesanynetstandard2.0contentFileslogging.config" />
</files>
</package>


The nuget package uses .Net Core 2.1, and.Net Framework 4.6.1. I've been advised by a senior dev to change it to .Net Standard.



Thanks, and I am looking forward to everyone's feedback!










share|improve this question









New contributor




DanStockham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm building a Nuget package that acts as a logger for other applications. One of the features it needs to house different config properties (slack webhook urls, application name, and etc...) and the developer can edit these values within the app.config or whatever is the config file.



One of the approaches I've used was creating transform files suggested by the documentation Microsoft provided here



However, when testing the nuget package on a console application with both .Net Framework and Core, the config files do not have the settings the transform files have from the nuget package. After some research, it turns out if the project uses PackageReference it cannot make changes to the configuration file.




For projects using packages.config, NuGet supports the ability to make transformations to source code and configuration files at package install and uninstall times. Only Source code transformations are applied when a package is installed in a project using PackageReference.




The last solution I tried was from this SO question here from one of the comments. However, still not seeing the change.



Right now, I'm outputting a config file after the build to the application's root folder. Then, the nuget package pulls the config properties into a class which can be shared among the different loggers.



Here is the nuspec file:



<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>POS_LoggingModule</id>
<version>1.0.13</version>
<authors>...</authors>
<owners>...</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Simple library to post logging to a Slack channel.</description>
<tags>Slack</tags>
<dependencies>
<group targetFramework=".NETStandard2.0">
<dependency id="Microsoft.Extensions.Configuration" version="2.1.1" exclude="Build,Analyzers" />
<dependency id="Newtonsoft.Json" version="11.0.2" exclude="Build,Analyzers" />
<dependency id="System.Diagnostics.EventLog" version="4.5.0" exclude="Build,Analyzers" />
</group>
</dependencies>
<contentFiles>
<files include="any/netstandard2.0/contentFiles/logging.config" buildAction="Content" />
</contentFiles>
</metadata>
<files>
<file src="binDebugnetstandard2.0POS_LoggingModule.dll" target="libnetstandard2.0POS_LoggingModule.dll" />
<file src="contentFileslogging.config" target="contentcontentFileslogging.config" />
<file src="contentFileslogging.config" target="contentFilesanynetstandard2.0contentFileslogging.config" />
</files>
</package>


The nuget package uses .Net Core 2.1, and.Net Framework 4.6.1. I've been advised by a senior dev to change it to .Net Standard.



Thanks, and I am looking forward to everyone's feedback!







c# .net .net-core nuget csproj






share|improve this question









New contributor




DanStockham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




DanStockham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 5 at 13:40





















New contributor




DanStockham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 5 at 2:06









DanStockham

12




12




New contributor




DanStockham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





DanStockham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






DanStockham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Hi there! Your question is too broad. Here, on stackoverflow, we dealing with coding issues, so if you have a problem with your code (exceptions, unpredictable behavior, etc.) - edit your question or ask another one. You may also find this link useful: stackoverflow.com/help/how-to-ask
    – JohnB
    Nov 5 at 5:56










  • Since you are using .NET Core, why not integrate with their Microsoft.Extensions.Configuration stack? App.config usage is possible again in recent versions but not really used. .NET Standard libraries for example can't rely on the target platform even supporting app.config
    – Martin Ullrich
    Nov 5 at 7:07










  • @johnB Could you elaborate more as to why the question is too broad?
    – DanStockham
    Nov 5 at 14:43


















  • Hi there! Your question is too broad. Here, on stackoverflow, we dealing with coding issues, so if you have a problem with your code (exceptions, unpredictable behavior, etc.) - edit your question or ask another one. You may also find this link useful: stackoverflow.com/help/how-to-ask
    – JohnB
    Nov 5 at 5:56










  • Since you are using .NET Core, why not integrate with their Microsoft.Extensions.Configuration stack? App.config usage is possible again in recent versions but not really used. .NET Standard libraries for example can't rely on the target platform even supporting app.config
    – Martin Ullrich
    Nov 5 at 7:07










  • @johnB Could you elaborate more as to why the question is too broad?
    – DanStockham
    Nov 5 at 14:43
















Hi there! Your question is too broad. Here, on stackoverflow, we dealing with coding issues, so if you have a problem with your code (exceptions, unpredictable behavior, etc.) - edit your question or ask another one. You may also find this link useful: stackoverflow.com/help/how-to-ask
– JohnB
Nov 5 at 5:56




Hi there! Your question is too broad. Here, on stackoverflow, we dealing with coding issues, so if you have a problem with your code (exceptions, unpredictable behavior, etc.) - edit your question or ask another one. You may also find this link useful: stackoverflow.com/help/how-to-ask
– JohnB
Nov 5 at 5:56












Since you are using .NET Core, why not integrate with their Microsoft.Extensions.Configuration stack? App.config usage is possible again in recent versions but not really used. .NET Standard libraries for example can't rely on the target platform even supporting app.config
– Martin Ullrich
Nov 5 at 7:07




Since you are using .NET Core, why not integrate with their Microsoft.Extensions.Configuration stack? App.config usage is possible again in recent versions but not really used. .NET Standard libraries for example can't rely on the target platform even supporting app.config
– Martin Ullrich
Nov 5 at 7:07












@johnB Could you elaborate more as to why the question is too broad?
– DanStockham
Nov 5 at 14:43




@johnB Could you elaborate more as to why the question is too broad?
– DanStockham
Nov 5 at 14:43

















active

oldest

votes











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',
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
});


}
});






DanStockham is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147409%2ftransforming-configuration-files%23new-answer', 'question_page');
}
);

Post as a guest





































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








DanStockham is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















DanStockham is a new contributor. Be nice, and check out our Code of Conduct.













DanStockham is a new contributor. Be nice, and check out our Code of Conduct.












DanStockham is a new contributor. Be nice, and check out our Code of Conduct.















 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147409%2ftransforming-configuration-files%23new-answer', 'question_page');
}
);

Post as a guest




















































































這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings