Nuget~ let the bag carry its own configuration information

Source: Internet
Author: User

We know that after the general development of the components, the components have related configuration items, The most common way is to write it into the Web. config, and if you put this file directly into NuGet packaging, when the installation package, will be prompted that the file already exists, not to overwrite the original config file, we can only write the configuration information in a text file, and the user after installing the package, but also Manually copy the information to their config file, it is very helpless, no one is willing to do this repetitive work!

Solve this situation

Use the Web.config.transform file to write your own personal information inside, it will automatically merge into the existing config file

For example Microsoft.AspNet.WebApi.Core also has this file, Nuget

The contents are as follows

<?xml version="1.0"encoding="Utf-8"?><configuration> <system.webServer> "Extensionlessurlhandler-isapi-4.0_32bit"/> <remove name="Extensionlessurlhandler-isapi-4.0_64bit"/> <remove name="extensionlessurlhandler-integrated-4.0"/> <add name="Extensionlessurlhandler-isapi-4.0_32bit"Path="*."verb="get,head,post,debug,put,delete,patch,options"modules="Isapimodule"Scriptprocessor="%windir%\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll"precondition="Classicmode,runtimeversionv4.0,bitness32"responsebufferlimit="0"/> <add name="Extensionlessurlhandler-isapi-4.0_64bit"Path="*."verb="get,head,post,debug,put,delete,patch,options"modules="Isapimodule"Scriptprocessor="%windir%\microsoft.net\framework64\v4.0.30319\aspnet_isapi.dll"precondition="Classicmode,runtimeversionv4.0,bitness64"responsebufferlimit="0"/> <add name="extensionlessurlhandler-integrated-4.0"Path="*."verb="get,head,post,debug,put,delete,patch,options"Type="System.Web.Handlers.TransferRequestHandler"precondition="integratedmode,runtimeversionv4.0"/> 

When we set up the VS API project, it automatically downloads the package from the NuGet server and merges the config file with the local file, and does feel quite practical and completely farewell to our copy work, hehe!

Nuget~ let the bag carry its own configuration information

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.