Exemple #1
0
        public static LockFile Read(string lockFilePath, Stream stream, bool designTime)
        {
            try
            {
                var reader  = new StreamReader(stream);
                var jobject = JsonDeserializer.Deserialize(reader) as JsonObject;

                if (jobject == null)
                {
                    throw new InvalidDataException();
                }

                var lockFile = ReadLockFile(lockFilePath, jobject);

                if (!designTime)
                {
                    var patcher = new LockFilePatcher(lockFile);
                    patcher.Patch();
                }

                return(lockFile);
            }
            catch (LockFilePatchingException)
            {
                throw;
            }
            catch
            {
                // Ran into parsing errors, mark it as unlocked and out-of-date
                return(new LockFile(lockFilePath)
                {
                    Version = int.MinValue
                });
            }
        }
Exemple #2
0
        public static LockFile Read(string lockFilePath, Stream stream, bool patchWithExportFile = true)
        {
            try
            {
                var reader  = new StreamReader(stream);
                var jobject = JsonDeserializer.Deserialize(reader) as JsonObject;

                if (jobject == null)
                {
                    throw new InvalidDataException();
                }

                var lockFile = ReadLockFile(lockFilePath, jobject);

                var patcher = new LockFilePatcher(lockFile);

                if (patchWithExportFile)
                {
                    patcher.PatchIfNecessary();
                }
                else
                {
                    patcher.ThrowIfAnyMsbuildLibrariesPresent();
                }

                return(lockFile);
            }
            catch (LockFilePatchingException)
            {
                throw;
            }
            catch
            {
                // Ran into parsing errors, mark it as unlocked and out-of-date
                return(new LockFile(lockFilePath)
                {
                    Version = int.MinValue
                });
            }
        }