简体   繁体   English

如何在WSP中包含配置文件?

[英]How to include config file in WSP?

I use NLog for logging and now I'm trying to also use it for my SharePoint solution. 我使用NLog进行日志记录,现在我正尝试将其用于我的SharePoint解决方案。
How do I instruct WSPBuilder to include NLog.config in WSP and place it in the same folder as solution dll? 如何指示WSPBuilder在WSP中包含NLog.config并将其与解决方案dll放在同一文件夹中?

EDIT: 编辑:

Okay, another option is to put it as Web.nlog in SharePoint 80 directory. 好的,另一个选择是将其作为Web.nlog放在SharePoint 80目录中。
Do I need a separate feature for this? 我需要一个单独的功能吗? What should I write in elements.xml ? 我应该在elements.xml写什么?

I don't think this can't be done - I assume for security reasons. 我认为这无法完成-出于安全原因,我认为。

DLLs can only be deployed to GAC (signed assemblies only) or to the bin directory of the web application (deployed via the solution manifest, along with any required CAS policies). DLL只能部署到GAC(仅限签名程序集)或Web应用程序的bin目录(通过解决方案清单以及任何必需的CAS策略进行部署)。

If you want extra files alongside the assembly in the bin directory, you'll need to copy them manually. 如果要在bin目录中的程序集旁边添加其他文件,则需要手动复制它们。

Does NLog.config need to be a separate file, or can the settings be integrated into the web.config file? NLog.config是否需要是一个单独的文件,还是可以将设置集成到web.config文件中? If you can integrate the settings into the web.config file, you can add a feature receiver and write the necessary settings during the FeatureActivated or FeatureInstalling event to web.config using SPWebConfigModifications (just google for it). 如果您可以将设置集成到web.config文件中,则可以使用SPWebConfigModifications(仅适用于google)添加功能接收器并将FeatureActivated或FeatureInstalling事件期间的必要设置写入web.config。 You should also make sure to remove the settings in FeatureDeactivating or FeatureUninstalled event. 您还应该确保删除FeatureDeactivating或FeatureUninstalled事件中的设置。

You should also take a look here : http://msdn.microsoft.com/en-us/library/ee413935.aspx 您还应该在这里看看: http : //msdn.microsoft.com/en-us/library/ee413935.aspx

I would also ask these questions : 我也会问这些问题:

  • Is the configuration the same for all the farm ? 所有服务器场的配置都一样吗? Only one web application ? 只有一个Web应用程序?
  • Can you programmaticaly specify NLog configuration ? 您可以以编程方式指定NLog配置吗?

Depending on your answers, I will suggest one or more solutions. 根据您的回答,我将建议一个或多个解决方案。 The disadvantages with the web.config are web.config的缺点是

  • Configuration is deployed on all SharePoint servers (the feature take care of that, but you have to keep that in mind in case of inconsistant behavior) 配置已部署在所有SharePoint服务器上(此功能可以解决此问题,但是在行为不一致时必须牢记这一点)
  • If you want to modify settings there is no easy way 如果要修改设置,没有简单的方法
  • Each time you modify settings, it will recycle application pool. 每次修改设置时,它将回收应用程序池。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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