NuGet release.config.install.xdt Retain Transforms - transform

I'm creating a NuGet package that contains a web.release.config.install.xdt file. But, every transform in the file is processed by NuGet.
Here's the contents of the web.release.config.install.xdt file:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!-- I only want this xdt:Transform to be handled by NuGet -->
<solr xdt:Transform="Insert">
<!-- the below xdt:Transform attributes are also processed by NuGet -->
<server id="location" url="http://192.168.1.100:8983/solr/geo" xdt:Transform="SetAttributes" xdt:Locator="Match(id)" />
</solr>
</configuration>
Any suggestions on the proper way to escape the nested transforms so they are retained for the web.release.config file?

Related

azure devops artifacts save Nugets to feed as backup incase nuget.org will be down

we want to keep the Nugets we use in our feed in case nuget.org will be down.
Under NuGet.Config we did:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="Nugets" value="https://pkgs.dev.azure.com/<ourOrganization>/<ourProject>/_packaging/Nugets/nuget/v3/index.json" />
</packageSources>
<packageRestore>
<!-- The 'enabled' key is True when the "Allow NuGet to download missing packages" checkbox is set.
Clearing the box sets this to False, disabling command-line, automatic, and MSBuild-integrated restore. -->
<add key="enabled" value="True" />
</packageRestore>
</configuration>
Now if I go to the artifacts -> Nugets I can see some of the package, appear as NugetGallery, but not all of them.
For example Newtonsoft.Json is missing.
Also when I look at the source - why are all of them under Nugetgalley, and not 'this feed'?
Thank you for your help.

How is it possible to add a NuGet Package source inside Azure Pipelines?

i am working with Azure Pipelines recently and i have a NuGet Task inside my Build process. This progress always fails, because there is no package called "BotUtility" inside the NuGet source. That is caused because this package is created by myself and is stored in Azure Artifacts only.
##[error]The nuget command failed with exit code(1) and error(NU1101: Unable to find package BotUtility. No packages exist with this id in source(s): NuGetOrg
Is it possible for the Build Pipeline to reach this package inside Azure Artifacts and if so, how can i implement this? Can i add the package feed source in the Pipeline config?
There is a more detailed screenshot of the error location.
Here is my current version of the Build pipeline.
Well you can add your nuget feed to the nuget task;
Another way is to define a nuget.config in your project, and add your package there:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- NuGet packages are now stored globally, see: https://stackoverflow.com/a/35809007/4122889 -->
<!-- see: https://stackoverflow.com/a/53451805/4122889 -->
<config>
<add key="globalPackagesFolder" value=".\Packages" />
<add key="repositoryPath" value=".\Packages" />
</config>
<!-- Setup for local packages, not in a nuget source -->
<packageSources>
<add key="MY_FEED" value="https://pkgs.dev.azure.com/org/project/_packaging/MY_FEED/nuget/v3/index.json" />
<!--<add key="LocalPackages" value="./LocalPackages" />-->
</packageSources>
<activePackageSource>
<!-- this tells that all of them are active -->
<!--<add key="All" value="(Aggregate source)" />-->
</activePackageSource>
</configuration>

How do you add an xml file to the App_Data folder of a web site and then modify it with NuGet

I am creating a NuGet package that adds or modifies several xml files. I want the Nuget package to add and then modify the xml files, so the user does not have to do anything to get the file added if it does not exist. I need to modify the xml file to customize it for the specific application.
The code I am using in the .nuspec file is:
<files>
<file src="web.config.*.xdt" target="content"/>
<file src="App_Data\*.xml" target="content\App_Data"/>
<file src="App_Data\*.xml.*.xdt" target="content\App_Data"/>
<file src="favicon.ico" target="content\favicon.ico"/>
</files>
The code with will add the file if they do not exist, or modify them if they do, but it won't add them and then modify them.
Each file I am trying to add then modify as a .install.xml.xdt file associated with it.
I am using a custom RoleManager. The xml file contents are:
<?xml version="1.0" encoding="utf-8" ?>
<roleManager />
The xml.install file contains:
<?xml version="1.0" encoding="utf-8" ?>
<roleManager xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"
xdt:Transform = "SetAttributes(defaultProvider,enabled,cacheRolesInCookie,cookieProtection)"
defaultProvider="RoleProvider"
enabled="true"
cacheRolesInCookie="true"
cookieProtection="All" >
<providers xdt:Transform="Insert" >
<clear />
<add name="RoleProvider" type="Library.RoleProvider" applicationName="$RootNamespace$" />
</providers>
</roleManager>
Is there any way to accomplish what I want to do?
I have a tentative approach to the problem: Create a dependent solution to add the files.
The dependent solution has the following nuspec section:
<files>
<file src="App_Data\*.xml" target="content\App_Data"/>
</files>
This nuget package is then listed as a dependency in the main library as such:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>Timothy R Dooling</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>Copyright 2017</copyright>
<file src="App_Data\*.xml" target="content\App_Data"/>
<dependencies>
<dependency id="LibraryCore" version="1.0.0" />
</dependencies>
</metadata>
<files>
<file src="web.config.*.xdt" target="content"/>
<file src="App_Data\*.xml.*.xdt" target="content\App_Data"/>
<file src="favicon.ico" target="content\favicon.ico"/>
</files>
</package>
The only hassle with this approach is that you have to uninstall the dependency or hand-delete the added files in order to completely undo the changes made to the application.
It would be preferable since such changes could involve more than one dependencies if the nuspec in the main package would know enough to uninstall the dependent package.
Anyone know how to get it to do that?

SlowCheetah not transforming root XML element with multiple attributes

I'm trying to add a SlowCheetah release transformation for my NLog.config file. The NLog.Release.config looks as follows:
<?xml version="1.0" encoding="utf-8"?>
<nlog
xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="true"
internalLogLevel="Off"
internalLogFile="c:\temp\nlog-internal.log"
xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"
xdt:Transform="Replace">
<extensions>
<!--<add assembly="NLog.Targets.RabbitMQ" />-->
</extensions>
<targets async="true">
<!--<target xsi:type="Console" name="console" error="false" layout="${time:format=HH:mm:ss} ${logger}: ${message} ${exception:format=ToString}"/>-->
</targets>
<rules>
<!--<logger name="*" minlevel="Trace" writeTo="console"/>-->
</rules>
</nlog>
Here, I'm trying to replace the whole contents of the file using xdt:Transform="Replace" on the root element. However, I'm getting the following error on build with Visual Studio 2015:
C:\Projects\WebSite\Properties\SlowCheetah\SlowCheetah.Transforms.targets(184,5):
error : Could not write Destination file: Object reference not set to
an instance of an object.
I did a few experiments, and found out that this error goes away if I remove all the attributes from the root nlog element (autoReload, throwExceptions, etc). But I need to replace the whole file, including all those attributes.
Why can't SlowCheetah perform this transformation? How can I make it transform the whole file, including all the attributes on the root element?

SubSonic - dividing up web.config

I'm trying to divide up my web.config into multiple config files so that when I import the DLL to other projects, the .config files will also be imported.
Issue is with SubSonicService:
I've defined:
configSections
*section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/*
/**configsections**
But this doesn't allow me to use the configFile attribute later on in my web.config.
The error I get in the web.config is:
The element 'SubSonicService' has incomplete content. List of possible elements expected: 'providers'.
Any tips?
Thanks.
I have this and it works.
web.config
<configuration>
<configSections>
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
<!--Other Sections-->
</configSections>
<SubSonicService configSource="SubSonic.config"/>
<!--Other Stuff-->
</configuration>
SubSonic.config
<SubSonicService defaultProvider="yadayada">
<providers>
<!--List Providers Hers-->
</providers>
</SubSonicService>
I remember reading something about making sure SubSonicService was the first section in the configSections.

Resources