Accessing Nuget Official Package Source behind company proxy - visual-studio-2010

I am trying to use Nuget in VS2010 at work. When I try and download packages from the official feed it always fails with a 403.
I've read that Nuget will use the same proxy settings as IE, which is unfortunate for me as my IE is locked down. I can't change the proxy.
I have fiddled the feedservice urls that are getting bounced, in IE I get an error, in Firefox (with a local proxy.pac defined) the urls resolve fine and I can see the feeds.
Is there any way to manually configure Nuget not to use IE's settings?

If you can't get the exception added to your proxy, or just want an immediate solution then edit your Visual studio configuration file (devenv.exe.config) located in your Visual Studio installation directory (eg - C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE) and change/add the <system.net> configuration section to the following, which will let Visual Studio work with the proxy:
<system.net>
<defaultProxy useDefaultCredentials="true" enabled="true">
<proxy proxyaddress="http://<Insert proxy address here>" />
</defaultProxy>
<settings>
<servicePointManager expect100Continue="false" />
<ipv6 enabled="true" />
</settings>
</system.net>
All you need to do is change the <Insert proxy address here> to your company's proxy address. Also depending on your proxy settings you may be able to use Expect100Continue messages and may not need to change that configuration element. You can find more information here

The following comes from a related question I answered recently.
Here's what I did to get this working with my corporate proxy that uses NTLM authentication. I downloaded NuGet.exe from a link on this page and then ran the following commands (which I found in the comments to this discussion on CodePlex):
nuget.exe config -set http_proxy=http://my.proxy.address:port
nuget.exe config -set http_proxy.user=mydomain\myUserName
nuget.exe config -set http_proxy.password=mySuperSecretPassword
This put the following in my NuGet.config located at %appdata%\NuGet (which maps to C:\Users\myUserName\AppData\Roaming on my Windows 7 machine):
<configuration>
<!-- stuff -->
<config>
<add key="http_proxy" value="http://my.proxy.address:port" />
<add key="http_proxy.user" value="mydomain\myUserName" />
<add key="http_proxy.password" value="base64encodedHopefullyEncryptedPassword" />
</config>
<!-- stuff -->
</configuration>
Incidentally, this also fixed my issue with NuGet only working the first time I hit the package source in Visual Studio.
Note that some people who have tried this approach have reported through the comments on my other answer that they have been able to omit setting the http_proxy.password key from the command line, or delete it after-the-fact from the config file, and were still able to have NuGet function across the proxy.
If you find, however, that you must specify your password in the NuGet config file, remember that you have to update the stored password in the NuGet config from the command line when you change your network login, if your proxy credentials are also your network credentials.

Well I managed to get the IT department to allow unrestricted access to packages.nuget.org, so that sorted it out. We use sophos here and any web request it doesn't like the look of is blocked. This applied to the nuget urls. A workaround was to use the Library Package Manager to initiate an installation with fiddler running. Then copy the url that was forbidden into my browser and tell sophos it's ok. I could then Install-Package successfully
hope this helps anyone stuck behind a militant firewall

If you don't know the proxy settings and NuGet is asking for a proxy user and password, you could try adding to devenv.exe.config file in your Visual Studio installation directory, between the <system.net> tags :
<defaultProxy useDefaultCredentials="true" enabled="true">
<proxy usesystemdefault="True"/>
</defaultProxy>
it should look like this, depending on your VisualStudio:
<system.net>
<defaultProxy useDefaultCredentials="true" enabled="true">
<proxy usesystemdefault="True"/>
</defaultProxy>
<settings>
<ipv6 enabled="true" />
</settings>
</system.net>
It worked for me without even giving the proxy address :)
Really this should be the default behavior, I lost so many days trying to overcome this...

I had a problem with accessing the Nuget site through the Nuget Console. "Received an unexpected EOF or 0 bytes from the transport stream." It ended up being a proxy issue, the difference was my work proxy is 'invisible' and doesn't have configuration options. I solved my problem with the following steps.
Open Visual Studio as Administrator
Open the Visual Studio internal browser ( View | Other Windows | Web Browser )
Go to your banks website - or other site that uses SSL
Might need to actually log in to the site, I didn't.
Then Run the Install-package command in the Nuget Console.
Command works without error.
This may help with the following issues:
https://nuget.codeplex.com/workitem/3176
https://nuget.codeplex.com/workitem/3403
I hope this helps.

Related

Unable to configure the PATH environment variable in Kudu shell via XDT

I am trying to set the PATH environment variable for a web app I am building in Azure in python. I tried to use something like os.environ.setdefault('PATH', 'pandoc-2.14.1-1-amd64.deb') locally, however this does not seem to work once uploaded. I have also tried setting the path in the configuration section on the azure portal, but get the following error:
I have seen posts like
setting the webapp %PATH% environment variable in azure.
The post recommends adding a file called applicationHost.xdt to the home/site directory, which should set the PATH variable automatically. However, I am unable to upload applicationHost.xdt to the files in the directory. This is either because the file UI interface no longer exists, or I am unable to access it. Has the ability to upload via the UI been discontinued?
The only other workaround I can think of is to use echo/cat in the Kudu bash shell to create the applicationHost.xdt manually. This is very tricky. Are there any online tools that, given an input of the contents of a file, create the bash script to generate that file from scratch?
You could add a App settings to you web app, like below:
Then, restart your web app, in Kudu console, you could check it.
Note: App setting names must be unique, so when you use PATH as key it is already configured while deploy so while using in App setting from portal use a different Key name.
As a workaround, you can achieve that through an XDT Transform (XML Document Transform).
Yes, you can use echo to create the same. Simple copy paste the content of the file to be inside single quote ' and stream it into the file already created using echo command.
/home>echo '<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<runtime xdt:Transform="InsertIfMissing">
<environmentVariables xdt:Transform="InsertIfMissing">
<add name="FOO" value="BAR" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
<add name="PATH" value="%PATH%;%HOME%\BAR" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
</environmentVariables>
</runtime>
</system.webServer>
</configuration>' > applicationHost.xdt
Verify the contents using cat command

Run nuget task in VSTS without proxy settings

So I think what I want is the opposite of this post: VSTS NuGet restore fails (proxy?)
We have an on-prem machine running a VSTS agent for builds. That machine has the http_proxy variable set so the agent process can talk to VSTS in the cloud.
I'm then trying to use the built in nuget task to do a nuget restore, but the feed I want to access is on an on-prem artifactory instance. To access this feed nuget needs to not use the proxy settings that the agent does (we have the 'bypass proxy for local addresses' option checked in Internet Options).
However, when I run the nuget task I see the following in my build log, it seems to set the nuget proxy to the agent proxy:
2017-10-17T14:02:14.4961204Z ##[debug]agent.proxyurl=http://X.X.X.X:8080
2017-10-17T14:02:14.4961204Z ##[debug]agent.proxyusername=undefined
2017-10-17T14:02:14.6992455Z ##[debug]agent.proxypassword=undefined
2017-10-17T14:02:14.7773706Z ##[debug]Adding environment variable for NuGet proxy: http://X.X.X.X:8080/
2017-10-17T14:02:14.7773706Z ##[debug]exec tool: C:\vsts-agent\_work\_tool\NuGet\4.0.0\x64\nuget.exe
(The 2 sets of X.X.X.X are identical in the real log)
I've tried setting a process variable of http_proxy="" and adding this line to my nuget.config <add key="http_proxy" value="" />, but it makes no difference.
Is there a way to run the nuget task without picking up the agent proxy?
If I just run nuget manually from a command line task in VSTS, it all works as expected.
The VSTS agent should be able to pick up the proxy exclusion settings from a .proxybypass file:
echo http://local.nuget.server >> .proxybypass
I'm not sure if the Nuget task will pick this up (it looks like it doesn't yet), but at least that's how you can tell the agent to ignore certain hosts. This was added in a very recent agent version, so you may need to upgrade your agent.
I'm guessing that if you use my VSTS Set Variable Task to temporarily set the value of agent.proxyurl to an empty string and restore it after calling the nuget task, that it should work for now.
PS the new configuration no longer uses the environment variable to set the proxy, the new default is to put that in a .proxy file in the agent root as well.

iis: applicationhost.config in iis express

I am using iis express 7.5. I ran the following to create a new website:
& 'C:\Program Files\IIS Express\appcmd.exe' add site /name:comm-app /id:2 /bindings:http/*:80:comm-app.local /physicalPath:C:\G_Drive\code\iis\www\CommunicationApp\public
I found this config was added to the config file in my documents folder here:
C:\Users\me\Documents\IISExpress\config\applicationhost.config
Then I decided to install the IIS console on my box and use that instead, but after installing and open the IIS console I can't see my new website. When look at the configuration editor I in the console I can see it is using the config file in the windows\system32\inetsrv.. directory:
Which config file is iis express actually using and how can I edit it with the console?
I should have mentioned before that immediately after installing iis express I install Zend server 6 (which I believe makes some config changes).
It appears my iis express is using the config file in the system folder and is working correctly.
If anyone else is using iis express with zend server maybe this will be helpful info.

Host Static Website with IIS Express

Is it possible to host just static files on IISExpress without a web.config?
I have a html5 Application Prototype (no serverside code) and I would like to host the website on IISExpress Webserver because there are a few json files simulating a REST-API which I access with AJAX.
There is a main.html file and some api/data.json files.
When Im creating a VS-Project everything works fine.
I delete all config and VS-related files and added the site manually with
appcmd add site /name:"HTMLStandalone" /bindings:http/*:56668 /physicalPath:"C:\Users\me\somefoler\myapp"
UPDATE: works fine, it results in the following entry in the applicationhost.config
<site name="HTMLStandalone" id="4">
<application path="/">
<virtualDirectory path="/" physicalPath="C:\Users\me\somefolder\myapp" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:56668" />
</bindings>
</site>
when I start the site
iisexpress.exe /site:HTMLStandalone
the process fails:
Failed to translate binding to url prefix *:56668
Registration completed for site "HTMLStandalone"
Failed to process sites
Report ListenerChannel stopped due to failure; ProtocolId:http, ListenerChannelI
d:0
HostableWebCore activation failed.
Is it possible to host just static files without a web.config?
web.config file is not mandatory. It seems your appcmd.exe command is little off... Run following command instead
appcmd add site /name:"HTMLStandalone" /bindings:http/*:56668: /physicalPath:"C:\Users\me\somefoler\myapp"
Note that, to run this site you must be running as administrator. If you want to run as non-administrator, run the following command
appcmd add site /name:"HTMLStandalone" /bindings:http/*:56668:localhost /physicalPath:"C:\Users\me\somefoler\myapp"
From the iis.net website
You can also use the /path option to run a site directly from a
folder. This option works for any type of application, including
static HTML, ASP.NET, PHP, and WCF. By default, IIS Express will run
the site on http://localhost:8080/. For a managed website, such as
ASP.NET, IIS Express will use .NET 4.0. You can use the /port and /clr
options to override these default values.
In my case this was not enough. /path and /config flags are not combinable. I wanted a custom applicationhost.config file (in order to add the mime-extenstions for json and text/cache-manifest)
The current solution was to add the bindings:http/*:56668:localhost
Alternativly to make the site available on the (local) network, you can use the dns-name of your pc/server, e.g. bindings:http:/*:56668:my-pc

Problem Unblocking Assemblies in Windows 7 Home Premium

I am getting the following error trying to load a basic project template:
Error 12 Could not load the assembly file://\\psf\home\documents\visual studio 2010\Projects\WindowsPhonePivotApplication1\WindowsPhonePivotApplication1\obj\Debug\WindowsPhonePivotApplication1.dll. This assembly may have been downloaded from the Web. If an assembly has been downloaded from the Web, it is flagged by Windows as being a Web file, even if it resides on the local computer. This may prevent it from being used in your project. You can change this designation by changing the file properties. Only unblock assemblies that you trust. See http://go.microsoft.com/fwlink/?LinkId=179545 for more information. WindowsPhonePivotApplication1
I don't have the Security tab when I try and modify the DLL to unblock the assembly. Any advice?
Did you try copying this assembly locally? Currently it seems to be loaded from a network share. You will need to trust that network location if you want to work this way.
Drive:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1 -url "file:////\computername\sharename*" FullTrust -exclusive on
Check this KB for details... http://support.microsoft.com/kb/320268/
I just ran into this very same problem - trying to compile a Silverlight application inside Parallels Desktop 8 virtual machine on a Mac - where the SL output directory was located on the emulated drive (appears in Windows as a network drive).
Very simple fix. You can open up devenv.exe.config located in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE and add this line inside the <Runtime> node:
<loadFromRemoteSources enabled="true"/>
e.g.
<?xml version ="1.0"?>
<configuration>
<configSections>
<section name="msbuildToolsets" type="Microsoft.Build.BuildEngine.ToolsetConfigurationSection, Microsoft.Build.Engine, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
...
<runtime>
<loadFromRemoteSources enabled="true"/>
...
To edit the devenv.exe.config file you will also need to open NotePad as administrator. After doing the above I can compile my SL application inside Parallels Virtual Machine, but the above also applies to Silverlight applications hosted on a network drive.
I ran into this. These were the steps I took:
Downloaded a file, WP7PiChartsFromDBSOUP.dll, to my downloads folder (everything locally).
Copied this file to c:/Program Files/ referenced it and attempted to build.
Got this error message.
Removed the reference, and followed the steps to unblock.
Referenced and attempted to build: still same error.
Went back to c:/Program files and noted that the file was still blocked. Somehow my attempt to block didn't take. So I tried to unblock, closed the properties dialog, then reopened. Somehow my attempt to unblock didn't appear to be working.
Went to the downloads folder and unblocked the file that was downloaded to this location, tried to unblock, and it seemed to work. So I felt like I was out of the woods. I copied this file over the file in c:/Program Files and reference it in VS2010, closing and reopening VS2010.
Same error message. I rebooted the machine and tried again. Same error message. And I know this is gonna sound crazy, but I renamed the dll from that long name to PieChart.dll.
And it finally worked.
So, either there was a problem with the name, or maybe changing the name somehow caused the change in blocked status to kick in.
I had the same problem trying to build an application on parallels.
I just copied the whole project in a folder under c:/ and works
it seems that parallels shares certain folders (i.e. desktop, documents) between the OS running on the vm and your mac user home folder. because of that windows treats these folders as network shared folder and forbids you to access them.
It's on the General tab in file properties from explorer. Either via the DLL in question, or you can do it on the zip file before you extract if it was a download, there will be an unblock button at the bottom right.
Make sure it's from a trusted source.
I've tried many solutions also with coping file to external usb drive with FAT32 file format, and some other ideas. But finally I've found post by caliban here: Topic about this problem. He links to a program called Streams which helped solving this problem :)
caliban:
Run this line in the command line
streams -s -d directory
download Streams exe
Add to the project a text file named ServiceReferences.ClientConfig having the following contents:
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
Re-build the project.
If you still didn't get your answer, I just found the solution. You are saving the application into the network hardrive. So while creating the application, change the location to something like your local disk e.g.,
C:/Projects
Then you will be able to run it.
I had the same problem over VMWare using a mac to load windows 7, if you see the path it starts like a network path, that's why VS gives out about the security.
Take the entire folder project and put it in a physical path starting with C://program files... , then open and compile, it will work.
Right click on the dll and select properties. You should see a button to unblock the assembly.

Resources