VS 2013 Not Obeying Nuget Configuration in AppData - visual-studio-2013

I have a file in %appdata%/nuget/nuget.config with following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="C:\BTR\packages" />
</config>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<disabledPackageSources />
<activePackageSource>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</activePackageSource>
</configuration>
Then in a project, I have the following in a packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net35" />
</packages>
If I delete the Newtonsoft dll from /bin and rebuild, I would expect it to download the package to c:\btr\packages, but it downloads it to \packages in same folder as solution.
Any ideas why this isn't obeying the setting? I don't (to my knowledge) have any other Nuget.config files anywhere that would override this setting.
Thanks in advance.
UPDATE : See Matt Ward's comment below.

Related

How do I transform this element in my Web.config?

I've been googling for about half the day here and I'm still just as clueless as when I started on this.
Here's the relevant portion of my Web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5.2"/>
</system.Web>
-->
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="DasExternalFileTransfer.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false"/>
</configSections>
<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">
<targets>
<target name="logfile" xsi:type="File" fileName="" layout="${longdate} ${callsite} ${level} ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile"/>
</rules>
</nlog>
I want to replace the fileName value under configuration/nlog/targets/target.
I have tried half a dozen different things in my Web.Dev.config. The latest would be
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<target xdt:Transform="Replace" xdt:Locator="XPath(/configuration/nlog/targets)" />
<target xdt:Transform="Replace" fileName="\\newlocation.ad\location1" />
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
To this point I have seen no effect when I preview my transform in Visual Studio.
I suspect that I am not defining the element in a way that the process can locate it, but I am not sure.
Could someone please help me figure out how to define the element properly so that I can replace the value with a new one? Or am I simply taking the wrong approach?
OK, THINK I'VE FIGURED IT OUT
It appears that the namespaces were tripping me up.
I modified this section of my Web.config
<nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
<targets>
<target name="logfile" xsi:type="File" fileName="" layout="${longdate} ${callsite} ${level} ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile"/>
</rules>
</nlog>
Note, I removed xmlns="http://www.nlog-project.org/schemas/NLog.xsd".
Then I modified my Web.Dev.config to
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
<targets>
<target xdt:Transform="SetAttributes(fileName)" xdt:Locator="Match(name)" name="logfile" fileName="\\newlocation.ad\location1" />
</targets>
</nlog>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
Then, when I preview the transform, I see this as the result <target name="logfile" xsi:type="File" fileName="\\newlocation.ad\location1" layout="${longdate} ${callsite} ${level} ${message}"/>.
I just hope now that the removal of the namespace will not adversely affect NLog, but I'll be testing to determine that.
It appears that the namespaces were tripping me up.
I modified this section of my Web.config
<nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
<targets>
<target name="logfile" xsi:type="File" fileName="" layout="${longdate} ${callsite} ${level} ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile"/>
</rules>
</nlog>
Note, I removed xmlns="http://www.nlog-project.org/schemas/NLog.xsd".
Then I modified my Web.Dev.config to
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
<targets>
<target xdt:Transform="SetAttributes(fileName)" xdt:Locator="Match(name)" name="logfile" fileName="\\newlocation.ad\location1" />
</targets>
</nlog>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
Then, when I preview the transform, I see this as the result <target name="logfile" xsi:type="File" fileName="\\newlocation.ad\location1" layout="${longdate} ${callsite} ${level} ${message}"/>.
I just hope now that the removal of the namespace will not adversely affect NLog, but I'll be testing to determine that.

How to prevent web.config reverting during publish to azure from Visual Studio

When I publish my .net core app to azure, the web.config seems to revert to something else and I can't figure out why.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="300000000" maxUrl="102410" maxQueryString="204810" />
</requestFiltering>
</security>
<applicationInitialization>
<add initializationPage="/" />
</applicationInitialization>
</system.webServer>
</configuration>
But what arrives on the server is this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\App.UI.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
The security and appinitialization sections completely disappear. What's going on here?

Spring boot on Azure produces internal server error

I want to deploy my jar on microsoft azure but it shows me an internal server error. the jar works on my pc fine, i added the following web.config file to my wwwroot:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar ";%HOME%\site\wwwroot\myjar.jar";">
</httpPlatform>
</system.webServer>
</configuration>
Unfortunately it does not work... I want to deploy it on a webApp in azure
It was a non-well formated xml file... now it works:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar %HOME%\site\wwwroot\myjar.jar" >
</httpPlatform>
</system.webServer>
</configuration>

IIS rewrite not working for simple redirects

All I want to do is 301 redirect from old URLs to new URLs:
from /xx/yy/somefile.html to /xx/yy/somefile.aspx
some examples below:
add key="/products/DSD-72B-SP-summary.html" value="/products/DSD-72B-SP-summary.aspx"
add key="/products/DSD-72B-SP-detail" value="/products/DSD-72B-SP-detail.aspx"
add key="index.html" value="default.aspx"
add key="/product-selector.html" value="/products.aspx"
That is all but it doesn't seem to want to work in IIS 7.5 with URL rewrite 2.0.
I have tried at least 10-20 different rules, and rewrite map formats without any luck.
In fact I have done this so many times I have had to wipe the rules and maps from IIS and totally recopy a web.config file from a backup to unscrew what I screwed with to try and make it work.
All I need is a simple rule that tells IIS that if it gets a request for a *.html file to display the *.aspx file that replaced the html file.
<?xml version="1.0" encoding="UTF-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings configProtectionProvider="DataProtectionConfigurationProvider">
<EncryptedData>
<CipherData>
</CipherData>
</EncryptedData>
</appSettings>
<connectionStrings configProtectionProvider="DataProtectionConfigurationProvider">
<EncryptedData>
<CipherData>
</CipherData>
</EncryptedData>
</connectionStrings>
<system.web>
<customErrors mode="On" defaultRedirect="404-NotFound.aspx">
<error statusCode="404" redirect="404-NotFound.aspx" />
<!--<error statusCode="403" redirect=""/>-->
</customErrors>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
<!--<codeSubDirectories>
<add directoryName="CSharp"/>
<add directoryName="VB"/>
</codeSubDirectories>-->
</compilation>
<authentication mode="Forms">
</authentication>
<membership>
<providers>
<clear />
</providers>
</membership>
<profile>
<providers>
<clear />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
</modules>
<defaultDocument>
<files>
</files>
</defaultDocument>
<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/404-NotFound.aspx" responseMode="ExecuteURL" />
</httpErrors>
<tracing>
<traceFailedRequests>
<add path="*">
<traceAreas>
<add provider="WWW Server" areas="Rewrite" verbosity="Verbose" />
</traceAreas>
<failureDefinitions statusCodes="200-500" />
</add>
</traceFailedRequests>
</tracing>
</system.webServer>
</configuration>
Make sure you clear your cache too. Sometimes you can update a server rule but your browser will continue to show the old page.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Vanity URL" enabled="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{MAPNAME:{PATH_INFO}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="MAPNAME">
<add key="/products/DSD-72B-SP-summary.html" value="/products/DSD-72B-SP-summary.aspx" />
</rewriteMap>
</rewrite>
</system.webServer>
</configuration>
The above code it taking directly from my website with minor name changes for generality and added in your page. Try to remove other rules and isolate the issue.

Combining web.config files

Need some help combining these if you can, please.
One is to allow .html and .htm files to act like .asp files for some includes and the other is for custom 404 pages.
I've tried all sorts of variations, but everything apart from using the files separately gives me a '500 - Internal Server Error' message.
web.config 1:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<handlers>
<add name="htmlinc" path="*.html" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
<add name="htminc" path="*.htm" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>
web.config 2:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" defaultPath="/404.htm" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.htm" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
<system.web>
<customErrors mode="On">
<error statusCode="404" redirect="/404.htm" />
</customErrors>
</system.web>
</configuration>
This should work. Check parent web.config files and look for issues cause by inheritance.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<handlers>
<add name="htmlinc" path="*.html" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
<add name="htminc" path="*.htm" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
</handlers>
<httpErrors errorMode="DetailedLocalOnly" defaultPath="/404.htm" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.htm" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
<system.web>
<customErrors mode="On">
<error statusCode="404" redirect="/404.htm" />
</customErrors>
</system.web>
</configuration>

Resources