Make the nuget cache local to the repo (#3370)

* fixes #3368

* Update build nuget cache to be in the repo
This commit is contained in:
Bryan Thornbury 2016-06-09 15:05:27 -07:00 committed by Piotr Puszkiewicz
parent 45d8f174aa
commit 1dc6b0e2dd
5 changed files with 11 additions and 20 deletions

3
.gitignore vendored
View file

@ -9,6 +9,9 @@
# NuGet keeps dropping
Library/
# local nuget cache
.nuget/
# NuGet v3 restore drops these even though we don't use MSBuild :(
*.nuget.targets
*.nuget.props

View file

@ -262,20 +262,8 @@ namespace Microsoft.DotNet.Cli.Build
{
var ciBuild = string.Equals(Environment.GetEnvironmentVariable("CI_BUILD"), "1", StringComparison.Ordinal);
if (ciBuild)
{
// On CI, HOME is redirected under the repo, which gets deleted after every build.
// So make NUGET_PACKAGES outside of the repo.
var nugetPackages = Path.GetFullPath(Path.Combine(c.BuildContext.BuildDirectory, "..", ".nuget", "packages"));
Environment.SetEnvironmentVariable("NUGET_PACKAGES", nugetPackages);
Dirs.NuGetPackages = nugetPackages;
}
// Set the package cache location in NUGET_PACKAGES just to be safe
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("NUGET_PACKAGES")))
{
// Always set the package cache location local to the build
Environment.SetEnvironmentVariable("NUGET_PACKAGES", Dirs.NuGetPackages);
}
CleanNuGetTempCache();

View file

@ -25,6 +25,7 @@ if($Help)
$env:CONFIGURATION = $Configuration;
$RepoRoot = "$PSScriptRoot\..\.."
$env:NUGET_PACKAGES = "$RepoRoot\.nuget\packages"
if($NoPackage)
{

View file

@ -57,6 +57,9 @@ while [[ $# > 0 ]]; do
shift
done
# Set nuget package cache under the repo
export NUGET_PACKAGES="$REPOROOT/.nuget/packages"
# Set up the environment to be used for building with clang.
if which "clang-3.5" > /dev/null 2>&1; then
export CC="$(which clang-3.5)"

View file

@ -45,11 +45,7 @@ namespace Microsoft.DotNet.Cli.Build
private static string GetNuGetPackagesDir()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), ".nuget", "packages");
}
return Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".nuget", "packages");
return Path.Combine(Dirs.RepoRoot, ".nuget", "packages");
}
}
}