2013-06-24 64 views
1

我爲我的Nuget包使用myget。因爲我使用具有憑證的私人飼料,我跟着這個博客:http://www.xavierdecoster.com/deploying-to-azure-web-sites-using-nuget-package-restore-from-a-secured-feed如何獲取myget包源代碼?

我的地方(項目)nuget.config(位於溶液中.nuget文件夾中)看起來是這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <solution> 
    <add key="disableSourceControlIntegration" value="true" /> 
    </solution> 
    <packageSource> 
    <clear /> 

    <add key="EcareMyGet" value="https://www.myget.org/F/rai69/"></add> 

    </packageSource> 
    <activePackageSource> 
    <add key="EcareMyGet" value="https://www.myget.org/F/rai69/"></add> 
    </activePackageSource> 
    <packageSourceCredentials> 
    <EcareMyGet> 
     <add key="Username" value="www.myget.org/raimond" /> 
     <add key="ClearTextPassword" value="wachtwoord" /> 
    </EcareMyGet> 
    </packageSourceCredentials> 
</configuration> 

在我nuget.targets我已經根據博客改變了restore命令:

<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -NonInteractive $(RequireConsentSwitch) -solutionDir "$(SolutionDir)\" -Verbosity detailed </RestoreCommand> 

儘管如此,buildserver依然採用nuget.org源:

NuGet.exe sources 
    Registered Sources: 

    1. https://nuget.org/api/v2/ [Enabled] 
     https://nuget.org/api/v2/ 

誰知道解決方案?

回答

1

答:通過< packageSources在nuget.config文件

以下取代<packageSource> >是導致答案的談話...

只是可以肯定,沒有你還可以閱讀禁用-RequireConsent開關的部分?

<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' "> 
false 
</RequireRestoreConsent> 

此外,還要確保你沒有在MSBuild的PackageSources元素,它在默認情況下看起來如下圖所示配置它(不包源配置):

<ItemGroup Condition=" '$(PackageSources)' == '' "> 
    <!-- Package sources used to restore packages. 
     By default, registered sources under %APPDATA%\NuGet\NuGet.Config 
     will be used --> 
    <!-- The official NuGet package source (https://nuget.org/api/v2/) will be 
     excluded if package sources are specified and it does not appear 
     in the list --> 
    <!-- 
     <PackageSource Include="https://nuget.org/api/v2/" /> 
     <PackageSource Include="https://my-nuget-source/nuget/" /> 
    --> 
</ItemGroup> 

如果你這樣做,這就是不這個問題,請你分享一下關於輸出日誌的更多細節,以便我可以確定問題何時發生以及通過什麼命令?

+0

我做到了。如果你想 –

+0

我可以給你發送原始文件隨意發送給[email protected],我們會仔細看看它。 –

+0

Thanx!發送文件! –

0

你寫你使用「我的本地(項目)nuget.config」,這讓我相信,你有nuget.config文件位於項目文件夾中。您可以閱讀NuGet Config File here。在那裏您會看到「NuGet首先從默認位置加載NuGet.config,然後從當前驅動器的根目錄開始加載任何名爲NuGet.config的文件,並在當前目錄結束。」

這意味着,它是會的NuGet尋找一路之根和的nuget.exe的位置,這通常是.nuget文件夾下在溶液中的文件夾層次結構根。這意味着它永遠不會看到解決方案中的項目文件夾。因此,您可以嘗試將您的nuget.config移動到解決方案文件夾,然後看它是否正確讀取。

+0

我的本地(項目)nuget.config位於解決方案中的.nuget文件夾中。 –

+0

您確定您正在運行* .nuget *文件夾內的* nuget.exe *文件嗎?因爲如果您在輸入'nuget'時處於解決方案根目錄,則可能會使用在您的環境變量中定義的PATH中找到的* nuget.exe *,然後它將找不到您的自定義配置文件。如果進入* .nuget *文件夾並明確運行位於那裏的* nuget.exe,會發生什麼?它會使用正確的配置值嗎? – Nailuj