I am little new to sitecore and I got a work thats bugging me. I was given a task to applying sitecore patches to the project and deploy to Dev. There were 3 patches. I completed the first two as it was to applied in Sitecore.config file. The third patch was to add config in "appSettings" node and "assemblyBinding" node in Web.config file. When I used the traditional way of patching like I used for the first two, I was getting an error and later I found out this:
My project doesn't use slowcheetah. I researched more about this and found that I have to do web config transforms. The more I researched how to do transforms more confused I got. Below are the config that I have to insert in Web.config :
In appSetting node :
<add key="Telerik.AsyncUpload.ConfigurationEncryptionKey" value="YOUR_ENCRYPTION_KEY_HERE" />
In assemblyBinding node :
<dependentAssembly>
<assemblyIdentity name="Telerik.Web.UI" publicKeyToken="121fae78165ba3d4" />
<bindingRedirect oldVersion="2015.1.401.45" newVersion="2017.2.621.45" />
</dependentAssembly>
I was hoping to get a simple solution or references to articles on how to do insert these configs in web.config file.
You can benefit from web.config file transformations. Transformations will allow you to have different values for different environments.There is a short and informative blog post by Martin Miles. It contains everything that is needed.
https://blog.martinmiles.net/post/how-apply-xml-transform-works-in-helix-habitat
Official Microsoft documentation has an example on how to apply transformations.
https://learn.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/web-config-transformations
As per the Sitecore Doc, we cannot create the patch for web.config
You can refer https://doc.sitecore.com/xp/en/developers/93/platform-administration-and-architecture/use-a-patch-file-to-customize-the-sitecore-configuration.html point 4 (Note)
enter image description here
Related
No answer required - experience documented for others
I wasted significant time and hope to save others the trouble
TLDR;
If you are trying to use Microsoft Dynamics CRM with an ASP.NET 5 MVC 6 (dnx / vnext) application, don't overthink it - just use the existing web.config file!
Personally, I got so wrapped up in the new configuration paradigm that the now obvious approach of just using the good 'ol web.config file to store the required configuration settings did not occur to me.
I was trying to connect to Microsoft Dynamics CRM; everything compiled and executed until I hit code that tries to create a CRM context generated using CrmSvcUtil.exe.
var xrm = new XrmServiceContext("Xrm");
The runtime error I got was, "A configuration element with the name 'Xrm' under the 'contexts' collection does not exist."
This simply means that there is something wrong with the configuration file. Now, I had an existing console application with the proper (working) configuration settings and I was trying to simply port them over to this vNext solution:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="microsoft.xrm.client" type="Microsoft.Xrm.Client.Configuration.CrmSection, Microsoft.Xrm.Client"/>
</configSections>
<connectionStrings>
<add name="Xrm" connectionString="Server=https://myserver.crm.dynamics.com; Domain=; Username=myUsername#domain.com;Password=myPassword"/>
</connectionStrings>
<microsoft.xrm.client>
<contexts default="Xrm">
<add name="Xrm" type="Xrm.XrmServiceContext, Xrm" connectionStringName="Xrm"/>
</contexts>
</microsoft.xrm.client>
</configuration>
My mistake, however, was a misguided attempt to use the new configuration paradigm and import the "Microsoft.Framework.Configuration.Xml" NuGet package. Then, I added the configuration file containing the necessary settings during Startup(): Again, this isn't the right approach; use web.config instead:
var builder = new ConfigurationBuilder(env.WebRootPath)
.AddXmlFile("config.xml")
.AddEnvironmentVariables();
It took me writing out the speculation here that the CRM dll's have no clue about the new IConfigurationSource approach. I knew there had to be another way and then my Friday night tired brain finally clicked..."Hey, I see a web.config file...I wonder if that would work." Yes, it does.
I integrated active directory with sitecore and it works perfect, now i am trying to write patches for the config changes. Sections <membership defaultProvider="sitecore" hashAlgorithmType="SHA1"> and <roleManager defaultProvider="sitecore" enabled="true"> are changed for connection setting to AD. When i try to write config patch for this section, this section is not built at run time. But the domains section works, i mean the patch i created for this section works and writes to web.config at runtime. I observed a difference here Domains section is under <Sitecore>, <membership> and <roleManager > are in <system.web> section. Is this the reason that these are not included in web.config? can we write patches for those sections only under <sitecore>?
Any ideas are appreciated.
Thanks.
You can only patch elements within the /configuration/sitecore element.
Refer this post:
http://www.sitecore.net/Learn/Blogs/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/05/All-About-Web-config-Include-Files-with-the-Sitecore-ASPNET-CMS.aspx
I think you have to use config transforms as mentioned by leandro.
I assumming you are using Visual Studio ¿? You must specify in what are you working.
If so, you need create a transform file for the build configuration that you need, for example, one config for every environment or publish type.
Try a look at this:
http://msdn.microsoft.com/en-us/library/vstudio/dd465318%28v=vs.100%29.aspx
I have implemented creation of subcommunities using IBM SBT 1.0.2.20140527-1807 against IC 4.5 (thanks for heavy API changes from 1.0.1 :-/ ) and want to update a freshly created subcommunity with a nice "content" containing some HTML with links to some content inside this community. Thus I must first create the subcommunity and afterwards update the "content" attribute, because I need some data not yet present before successful creation.
The way I do this is basically as follows:
(1) Create subcommunity [proven successful, and it IS a subcommunity now]
(2) Fetch the new subcommunity using CommunityService.getCommunity(communityUuid) [proven successful]
(3) execute community.setContent(string) [no errors]
(4) execute CommunityService.updateCommunity(community) [no errors]
The REST request created and sent for CREATE is:
POST /communities/service/atom/community/subcommunities?communityUuid=8ea4ff45-ef58-4c9b-b131-def2d3e233f7
The XML data sent is:
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
<title type="text">mytitle</title>
<content type="html">mycontent</content>
<category term="community" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category>
<category term="mytag"></category>
<snx:communityType xmlns:snx="http://www.ibm.com/xmlns/prod/sn">private</snx:communityType>
</entry>
The REST request created and sent for UPDATE is:
PUT /communities/service/atom/community/instance?communityUuid=ae63bedf-98f2-45d4-ad6a-4dfd1f3a58d7
The XML data sent is:
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
<title type="text">mytitle</title>
<content type="html">mycontent</content>
<category term="community" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category>
<category term="mytag"></category>
<snx:communityType xmlns:snx="http://www.ibm.com/xmlns/prod/sn">private</snx:communityType>
<snx:communityUuid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">ae63bedf-98f2-45d4-ad6a-4dfd1f3a58d7</snx:communityUuid>
<id>http://communities.ibm.com:2006/service/atom/community/instance?communityUuid=ae63bedf-98f2-45d4-ad6a-4dfd1f3a58d7</id>
</entry>
Afterwards the content is indeed updated -- but the community is not a subcommunity any more, but a regular top level community.
Why is that?
What can I do about it?
For the impatient: I have found the root cause, and in some circumstances this offers the possibility for a workaround.
The root cause is that the Community representation in IBM SBT SDK (Java) currently (as of July 2014) does not offer a "parent community URL" element.
http://www-10.lotus.com/ldd/appdevwiki.nsf/xpDocViewer.xsp?lookupName=IBM+Connections+4.5+API+Documentation#action=openDocument&res_title=Community_entry_content_ic45&content=pdcontent says that a community XML representation has a <link rel="http://www.ibm.com/xmlns/prod/sn/parentcommunity" type="application/atom+xml" href="..." /> element (where href is the atom/instance URL, not the "community URL" with html/communityview) if it represents a subcommunity, which is ignored on PUT/POST -- but:
THIS IS NOT TRUE:
In fact this element is REQUIRED on PUT to keep a community's "sub community" nature on change. And worse: If it is broken, it cannot be "repaired": Because of other limitations for subcommunities, an existing community cannot be changed to become a subcommunity of another top level community. Subcommunities can only be CREATED (and kept, of course).
What I have done to work around that pitfall is to subclass Community and some other classes to extend the XML marshal/unmarshal mechanisms in SBT SDK to cope with parent community URLs. If you know what you're doing everything is fine, but if you want generic code which simply does not break subcommunities, you must also READ ALL COMMUNITIES as if they may be subcommunities. If you don't, you won't see this information and write back the community as top level community.
Thus it is better to wait if you can :-(
I expect IBM to extend the implementation of Community and related classes by a parent community URL field. What I am curious about is how they will deal with the fact that the complete Atom feed URL is required, including the server address and the parent community UUID. I took the q&d way and changed the community URL as returned by parentCommunity.getCommunityUrl(), but this eventually does not take into account the various AUTH variants.
IBM SBT SDK 1.1.0 of Jul 17, 2014, seems to be out. At least it is available in Maven central.
This is the better answer of course but will require several code adjustments if you have built code on top of internal structures due to some internal refactorings.
With some custom logic I have added a template for my web config in my Asp Mvc 4 application. When I need to modify the web.config file I am editing the template file for it and the changes are replaced in the web config file when I run the application. The problem is that when I add a package via nuget which needs to modify the web config file I am losing those settings as everything is overriden from my template file. Is there a way to somehow force the nuget packages to modify some custom xml file instead of the original web config file. For example, to modify mytemplate.xml instead of web.config.xml.
I am very new in this area and couldn't find a solution for my problem. As far as I understand packages that need to modify the web.config file come with web.config.transform file that merges the required fields and my only solutions is to manually replace the settings added to my web config file by the package into the template file. Is there another solution ? Thanks!
You are using your web.config file to do two different things:
Static configuration for nuget packages
Dynamic configuration for your site
web.config files allow you to define some of your settings in an external file and import them - e.g.
<configuration>
...
<appSettings configSource="appSettings.config" />
...
</configuration>
This is appSettings.config:
<appSettings>
<add key="umbracoDbDSN" value="..."/>
<add key="DefaultInstanceName" value="..."/>
<add key="aspnet:MaxHttpCollectionKeys" value="..."/>
</appSettings>
It's unlikely that you need to completely re-generate your web.config every build, probably only specific sections - if these don't clash with your installed packages then this approach would give you the flexibility your application needs.
OR PLAN B
packages.config lists all of the active packages in your solution
Packages store their web.config settings in a local file:
/packages/package/content/Web.config.transform
Can you extend the process that builds your web.config file to:
Enumerate the active packages
Check for a content/Web.config.transform file
Merge those files into your web.config build pipeline
I can't see any way of re-configuring nuget to push the configuration into a different file.
I am fairly green at ASP.NET coding, even though I have done very basic tasks for a while.
Recently, I have been assigned our company's website, so I am learning more of the details.
I downloaded the project from Source Safe, and I am making changes in the code.
A co-worker and I were looking at the Web.config file, and noticed this under the <configuration> section:
<appSettings>
<add key="HR_EMAIL" value="myEmailAddress#work.com"/>
<add key="APP_MODE" value="TEST"/>
<!-- PROD is the production value for ssl pages -->
<add key="HR_EMAIL_SITE_A" value="myEmailAddress#work.com"/>
<add key="HR_EMAIL_SITE_B" value="myEmailAddress#work.com"/>
</appSettings>
where myEmailAddress#work.com used to list my actual email address.
My co-worker said, "Oh, you've changed it and removed my email address."
Uh, no I have not! I could care less if these people email me!
I'm guessing something configured on my local machine (maybe in machine.config) went in and updated these values whenever I rebuilt the project.
I have used a walkthrough recently published by Microsoft (Walkthrough: Creating a Web Site with Membership and User Login), but it was in a different project.
What changed these values? Surely I did not do this in my sleep!
Chances are that someone committed these values to source control.
You got the latest value - possibly your workmate has not updated this file in a while.
Take a look at the file history in Source Safe to see what happened with this value.
section, as the name suggests, is specific to application to store custom settings. Before ASP .NET 2, this section was used to store things like connection string used by the web application.
In you case, I am guessing that, you have an admin site/system that is writing out your email adress to app.config.
I have seen another scenario, where setting will be updated by the build/release script.
You'll likely find that due to differences in enviroments, in most cases you don't deploy a web.config from enviroment to enviroment. You wouldn't want test settings, like connection strings, emails, etc getting propigated to production.
When you're likely finiding is the config in VSS is a local testing copy and the production copy has different values.