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 # NuGet keeps dropping
Library/ Library/
# local nuget cache
.nuget/
# NuGet v3 restore drops these even though we don't use MSBuild :( # NuGet v3 restore drops these even though we don't use MSBuild :(
*.nuget.targets *.nuget.targets
*.nuget.props *.nuget.props

View file

@ -261,21 +261,9 @@ namespace Microsoft.DotNet.Cli.Build
public static BuildTargetResult CheckPackageCache(BuildTargetContext c) public static BuildTargetResult CheckPackageCache(BuildTargetContext c)
{ {
var ciBuild = string.Equals(Environment.GetEnvironmentVariable("CI_BUILD"), "1", StringComparison.Ordinal); var ciBuild = string.Equals(Environment.GetEnvironmentVariable("CI_BUILD"), "1", StringComparison.Ordinal);
if (ciBuild) // Always set the package cache location local to the build
{ Environment.SetEnvironmentVariable("NUGET_PACKAGES", Dirs.NuGetPackages);
// 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")))
{
Environment.SetEnvironmentVariable("NUGET_PACKAGES", Dirs.NuGetPackages);
}
CleanNuGetTempCache(); CleanNuGetTempCache();

View file

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

View file

@ -57,6 +57,9 @@ while [[ $# > 0 ]]; do
shift shift
done 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. # Set up the environment to be used for building with clang.
if which "clang-3.5" > /dev/null 2>&1; then if which "clang-3.5" > /dev/null 2>&1; then
export CC="$(which clang-3.5)" export CC="$(which clang-3.5)"

View file

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