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!
c# .net .net-core nuget csproj
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.
add a comment |
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!
c# .net .net-core nuget csproj
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
add a comment |
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!
c# .net .net-core nuget csproj
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
c# .net .net-core nuget csproj
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.
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
add a comment |
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
add a comment |
active
oldest
votes
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.
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.
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
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
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
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
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
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