简体   繁体   中英

Web.config transform and publish

Seems I never really understood what correct settings are for the web.config file are, considering the publishing of an app. I have the typical Web.config file along with Web.Debug.Config and Web.Release.Config transforms. I want to publish changes in the web.config as a result of any updates as well as the transformed results - the server.

What should the file properties be for Build action Copy to Output Directory

For the above 2 settings, I have for the Web.config: Content , Copy if newer and for the transform files, Build action = none and Copy to... = Do not copy.

However, I am getting an error when I publish: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS

Whats happening, is during my publish, its copying the web.config to the bin folder locally. This is likely because on the Build settings of the App itself, the Output path is set to bin\\ so this is where the transformed web.config is being copied to.

So how do I handle publishing changes with the web.config? Just handle them manually, setting the web.config to never be copied over?

Change the Copy to Output Directory to 'Do not copy' on the web.config and then change the build action to 'Content'. That will copy up the web.config on publish but not place it in the \\bin directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM