Config transformation special situation - web-config

I have the following config file
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="Demo" value="true"/>
<setting name="Demo2" value="true"/>
</settings>
</sitecore>
</configuration>
And I want it transformed into this
<configuration xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
<sitecore role:require="Standalone OR ContentDelivery OR ContentManagement">
<settings>
<setting name="Demo" value="false"/>
<setting name="Demo2" value="true"/>
</settings>
</sitecore>
</configuration>
I have tried to use this https://fatantelopetester.apphb.com/ and obtained the following transformation config file:
<?xml version="1.0" encoding="utf-16"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xdt:Transform="SetAttributes(xmlns:role,xmlns:set)" xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<sitecore role:require="Standalone OR ContentDelivery OR ContentManagement" xdt:Transform="SetAttributes(role:require)">
<settings>
<setting name="Demo" xdt:Locator="Match(name)" value="false" xdt:Transform="SetAttributes(value)" />
</settings>
</sitecore>
</configuration>
But apparently this transformation is not good enough and not working.
Any ideas how to make it work, in conditions when under
<sitecore>
I have lots of other setting? (Here I've added just a sample)

I just ran into a similar issue myself and found a solution that worked for me. I'm not using SlowCheetah but I am using a tool that uses XDT under the hood.
The XDT would fail around xdt:Transform="SetAttributes(role:require)" because the namespace wasn't found. However, using xdt:Transform="SetAttributes" didn't seem to have the same problem and was able to set the attribute just fine.

Related

IIS 10 - web.config - how to enable default document without script access

We have a folder which contains only static html and images etc. No scripts should be allowed to execute from within this folder. However we would still like to be able to use html default documents.
What is the correct way to configure this?
This is the web.config file...
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers accessPolicy="Read"/>
<defaultDocument enabled="true">
<files>
<clear />
<add value="default.html" />
<add value="default.htm" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
If I attempt to access http://mysite/mystaticfolder/ it fails with the error...
HTTP Error 403.1 - Forbidden
However the URL http://mysite/mystaticfolder/default.html works fine.
Surely it shouldn't be nescessary to allow dynamic scripts, just to be able to serve static html default documents?
In case it helps anyone, I've been able to solve it with the following...
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers accessPolicy="Read">
<clear/>
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule" resourceType="Either" requireAccess="Read" />
</handlers>
<defaultDocument enabled="true">
<files>
<clear />
<add value="default.html" />
<add value="default.htm" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
I'm not entirely sure though why this doesn't work by default though.

VSO Build not able to download packages

I have the following nuget.config file and bellow is the file content
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="Packages" />
</config>
<packageRestore>
<add key="enabled" value="True" />
</packageRestore>
<packageSources>
<!-- Ditch all the Global NuGet package sources we only want a
single private NuGet repo for this project -->
<clear />
<add key="private="private" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<disabledPackageSources>
<add key="nuget.org" value="false" />
</disabledPackageSources>
</configuration>
All the packages which exist in the private feed are restored but the same is not happening with the ones in nuget.org:
From VSO build output
Feeds used:
C:\Users\buildguest\AppData\Local\NuGet\Cache
private
https://www.nuget.org/api/v2/
...
Restoring NuGet package AutoMapper.5.2.0.
WARNING: Unable to find version '5.2.0' of package 'AutoMapper'.
This is happening during the NuGet restore step in VSO.
Use NuGet.Protocol.Core.v3 feed protocol with
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
instead of
<add key="nuget.org" value="https://nuget.org/api/v2/" />
enter image description here
Inside Nuget.config put the bellow code.
<configuration>
<packageRestore>
<add key="enabled" value="True"/>
<add key="automatic" value="True"/>
</packageRestore>
</configuration>

NuGet Package transform a config transform file

Is there a way to make a NuGet package transform a config transform file? For example, when I want my NuGet package to edit a web.config file, I create a web.config.install.xdt file. But what if I want my NuGet package to edit a web.config.debug file?
I tried making a web.config.debug.install.xdt file, but ran into one issue: I cannnot get the transformation to insert attributes that are themselves attributes of xdt transformation. Something like:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt1="http://schemas.microsoft.com/XML-Document-Transform">
<system.serviceModel >
<client xdt1:Transform="Insert">
<endpoint address="http://blah.blah" binding="basicHttpBinding" contract="Test.Contract"
name="TestWs" xdt:Transform="Replace" xdt:Locator="Match(name)"/>
</client>
</system.serviceModel>
</configuration>
(I tried changing the namespace of xdt, but that didn't help either.)
Although this isn't perhaps the best answer, it did get the job done for me when I found myself in this situation:
Use the "old" method of doing transforms, not the xdt way.
https://docs.nuget.org/create/Transforming-Configuration-Files-Using-dotTransform-Files.md
This seems to work well, just make sure the appropriate xmlns attribute is in the .transform file.
For example, if you wanted to transform your web.qa.config file that currently looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="Tier" value="qa" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
</appSettings>
</configuration>
You could add an element:
<add key="RedirectUri" value="yourRedirectUriForQA" xdt:Transform="Replace" />
By adding the following web.qa.config.transform file to your Nuget package:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="RedirectUri" value="yourRedirectUriForQA" xdt:Transform="Replace" />
</appSettings>
</configuration>
Just make sure also to add it to the .nuspec file so it gets picked up when packaged.

Is it possible to import/add eclipse code formatter .xml in SonarQube?

The code below is a sample of what eclipse code format I want to use.
<profiles version="11">
<profile kind="CodeFormatterProfile" name="equationStyle" version="11">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
.
.
.
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
</profile>
</profiles>
Is it possible to import/add this to SonarQube?
No this is not possible.This request partially relates to http://jira.codehaus.org/browse/SONARIDE-112

Cannot create Azure Service Project Package using Azure CmdLets

I have a cloud service project in VS 2013 RTM.
I use Save-AzureServiceProjectPackage -Local command to generate CSPKG package. I am getting following error. Not sure why. Can anybody help.
Here is my Cloud CSCFG File -
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="WindowsAzure1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2013-10.2.2">
<Role name="WebRole1">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
And here is my Service Definition CSDEF file -
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="WindowsAzure1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2013-10.2.2">
<WebRole name="WebRole1" vmsize="Small">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
</Imports>
</WebRole>
</ServiceDefinition>
Appreciate any help.
The latest version of Windows Azure PowerShell doesn't support packaging VS projects. The new version which will be early December 2013 will have this support.