Exemplo n.º 1
0
            public CacheWriter(ResolvePackageAssets task, Stream stream = null)
            {
                _targetFramework = NuGetUtils.ParseFrameworkName(task.TargetFrameworkMoniker);

                _task                      = task;
                _lockFile                  = new LockFileCache(task).GetLockFile(task.ProjectAssetsFile);
                _packageResolver           = NuGetPackageResolver.CreateResolver(_lockFile);
                _compileTimeTarget         = _lockFile.GetTargetAndThrowIfNotFound(_targetFramework, runtime: null);
                _runtimeTarget             = _lockFile.GetTargetAndThrowIfNotFound(_targetFramework, _task.RuntimeIdentifier);
                _stringTable               = new Dictionary <string, int>(InitialStringTableCapacity, StringComparer.Ordinal);
                _metadataStrings           = new List <string>(InitialStringTableCapacity);
                _bufferedMetadata          = new List <int>();
                _platformPackageExclusions = GetPlatformPackageExclusions();

                if (stream == null)
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(task.ProjectAssetsCacheFile));
                    stream  = File.Open(task.ProjectAssetsCacheFile, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
                    _writer = new BinaryWriter(stream, TextEncoding, leaveOpen: false);
                }
                else
                {
                    _writer = new BinaryWriter(stream, TextEncoding, leaveOpen: true);
                }
            }
Exemplo n.º 2
0
            public CacheWriter(ResolvePackageAssets task)
            {
                var targetFramework = NuGetUtils.ParseFrameworkName(task.TargetFrameworkMoniker);

                _task              = task;
                _lockFile          = new LockFileCache(task.BuildEngine4).GetLockFile(task.ProjectAssetsFile);
                _packageResolver   = NuGetPackageResolver.CreateResolver(_lockFile, _task.ProjectPath);
                _compileTimeTarget = _lockFile.GetTargetAndThrowIfNotFound(targetFramework, runtime: null);
                _runtimeTarget     = _lockFile.GetTargetAndThrowIfNotFound(targetFramework, _task.RuntimeIdentifier);
                _stringTable       = new Dictionary <string, int>(InitialStringTableCapacity, StringComparer.Ordinal);
                _metadataStrings   = new List <string>(InitialStringTableCapacity);
                _bufferedMetadata  = new List <int>();

                var stream = File.Open(task.ProjectAssetsCacheFile, FileMode.Create, FileAccess.ReadWrite, FileShare.None);

                _writer = new BinaryWriter(stream, TextEncoding, leaveOpen: false);
            }