Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot restore nuget packages in C# when some packages in custom repository
    primarykey
    data
    text
    <p>I'm writing a building application, this application can get the latest code from TFS, and then build them into DLLs. This application is hosted as ASP.NET web application, the application pool is run with my domain account.</p> <p>Our code use <a href="http://www.nuget.org/" rel="nofollow">NuGet</a> to manage dependencies. And we have a local repository in our intranet, some dependencies <strong>ONLY</strong> in this local repository.</p> <p>If I ran below command in the CMD,</p> <pre><code>D:\MyApplication\nuget.exe restore </code></pre> <p>Result is:</p> <pre><code>Installing 'My_Dependency_Only_In_Local_1 1.0.0'. Installing 'My_Dependency_Only_In_Local_2 2.0.0'. Successfully installed 'My_Dependency_Only_In_Local_1 1.0.0'. Successfully installed 'My_Dependency_Only_In_Local_2 2.0.0'. All packages listed in packages.config are already installed. </code></pre> <p>All the dependencies can be downloaded correctly. But in my C# code</p> <pre class="lang-cs prettyprint-override"><code>var processInfo = new ProcessStartInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "nuget.exe"), "restore " + localProjectPath) { WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory, UseShellExecute = false, RedirectStandardError = true, CreateNoWindow = true, //Password = mypassword, //UserName = myusername, //Domain = mydomainname }; var process = Process.Start(processInfo); process.WaitForExit(); string errorText = process.StandardError.ReadToEnd(); </code></pre> <p>unless I uncomment the <code>Password</code>, <code>UserName</code>, <code>Domain</code>, set the user info explicitly, I would got the below error:</p> <pre><code>Unable to find version '1.0.0' of package 'My_Dependency_Only_In_Local_1'. Unable to find version '2.0.0' of package 'My_Dependency_Only_In_Local_2'. </code></pre> <p>I have no idea why this happened? This application is run by my account, and the <code>Process</code> I started might also run by my account, this command is works when running in CMD, but why not in my C# code?</p> <p>Would you help me? Thank you in advanced.</p> <p>PS: the nuget configuration is like below:</p> <p>%APPDATA%\NuGet\NuGet.Config</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;configuration&gt; &lt;packageRestore&gt; &lt;add key="enabled" value="True" /&gt; &lt;add key="automatic" value="True" /&gt; &lt;/packageRestore&gt; &lt;packageSources&gt; &lt;add key="intranet repository" value="http://our/local/nuget/repository" /&gt; &lt;add key="nuget.org" value="https://www.nuget.org/api/v2/" /&gt; &lt;/packageSources&gt; &lt;disabledPackageSources&gt; &lt;add key="local cache" value="true" /&gt; &lt;/disabledPackageSources&gt; &lt;activePackageSource&gt; &lt;add key="All" value="(Aggregate source)" /&gt; &lt;/activePackageSource&gt; &lt;/configuration&gt; </code></pre> <p>--</p> <p><strong>UPDATE</strong>:</p> <p>I wrote a console application, rename it to nuget.exe, and overwrites the real one.</p> <pre><code>private static void Main(string[] args) { File.WriteAllText("D:\\temp\\user.txt", System.Security.Principal.WindowsIdentity.GetCurrent().Name); } </code></pre> <p>It shows, nuget.exe is run with my domain account.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload