Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 47cb2a5

Browse files
committed
Merge pull request #2148 from dotnet-bot/from-tfs
Merge changes from TFS
2 parents f2acba3 + 0c99692 commit 47cb2a5

File tree

5 files changed

+64
-21
lines changed

5 files changed

+64
-21
lines changed

dir.props

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151

5252
<NugetRestoreCommand>"$(NuGetToolPath)"</NugetRestoreCommand>
5353
<NugetRestoreCommand>$(NugetRestoreCommand) install</NugetRestoreCommand>
54-
<NugetRestoreCommand>$(NugetRestoreCommand) -OutputDirectory "$(PackagesDir.TrimEnd('/'))"</NugetRestoreCommand>
54+
<!-- NuGet.exe doesn't like trailing slashes in the output directory argument -->
55+
<NugetRestoreCommand>$(NugetRestoreCommand) -OutputDirectory "$(PackagesDir.TrimEnd('/\'.ToCharArray()))"</NugetRestoreCommand>
5556
<NugetRestoreCommand>$(NugetRestoreCommand) $(NuGetConfigCommandLine)</NugetRestoreCommand>
5657
<NugetRestoreCommand>$(NugetRestoreCommand) -Verbosity detailed</NugetRestoreCommand>
5758
<NugetRestoreCommand Condition="'$(OsEnvironment)'=='Unix'">mono $(NuGetRestoreCommand)</NugetRestoreCommand>
@@ -77,7 +78,7 @@
7778
<DnuRestoreCommand>"$(DnuToolPath)"</DnuRestoreCommand>
7879
<DnuRestoreCommand>$(DnuRestoreCommand) restore</DnuRestoreCommand>
7980
<DnuRestoreCommand>$(DnuRestoreCommand) --parallel</DnuRestoreCommand>
80-
<DnuRestoreCommand>$(DnuRestoreCommand) --packages "$(PackagesDir.TrimEnd('/'))" $(DnuRestoreSource)</DnuRestoreCommand>
81+
<DnuRestoreCommand>$(DnuRestoreCommand) --packages "$(PackagesDir.TrimEnd('/\'.ToCharArray()))" $(DnuRestoreSource)</DnuRestoreCommand>
8182
<DnuRestoreCommand Condition="'$(LockDependencies)' == 'true'">$(DnuRestoreCommand) --lock</DnuRestoreCommand>
8283
</PropertyGroup>
8384

dir.targets

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@
5959
</Task>
6060
</UsingTask>
6161

62+
<!--
63+
Use a semaphore file to determine the need to restore build tools to avoid conflicts with locked binaries.
64+
-->
65+
<PropertyGroup>
66+
<BuildToolsSemaphore>$(ToolsDir)BuildTools.semaphore</BuildToolsSemaphore>
67+
</PropertyGroup>
68+
6269
<!--
6370
Needed to avoid the IntialTargets from having an Output which ends up getting
6471
added to the output references when you have a project to project reference.
@@ -67,7 +74,7 @@
6774

6875
<Target Name="_RestoreBuildTools"
6976
Inputs="$(MSBuildThisFileDirectory)dir.props;$(SourceDir).nuget/packages.$(OsEnvironment).config"
70-
Outputs="$(ToolsDir)Microsoft.DotNet.Build.Tasks.dll;$(NugetToolPath);$(DnuToolPath)">
77+
Outputs="$(BuildToolsSemaphore)">
7178
<Message Importance="High" Text="Restoring build tools..." />
7279

7380
<Copy Condition="Exists('$(NuGetCachedPath)')" SourceFiles="$(NuGetCachedPath)" DestinationFiles="$(NuGetToolPath)" SkipUnchangedFiles="true" />
@@ -95,16 +102,17 @@
95102
<Exec Condition="'$(OsEnvironment)'=='Unix'"
96103
Command="find '$(RoslynPackageDir)tools' -name &quot;*.exe&quot; -exec chmod &quot;+x&quot; '{}' ';'" />
97104

98-
<Error Condition="'$(ErrorIfBuildToolsRestoredFromIndividualProject)'=='true'"
99-
Text="The build tools package was just restored and so we cannot continue the build of an individual project because targets from the build tools package were not able to be imported. Please retry the build the individual project again." />
100-
101105
<!--
102-
There are cases where the inputs could be newer than the outputs but the
103-
download or restore may not need to update. In such cases we need to touch
104-
these files otherwise we continually run this target over and over for
105-
every project until these files are cleaned (if the are ever cleaned).
106+
Touch our semaphore file to ensure Inputs/Outputs comparison for this target will show that we're up to date.
107+
Ignore failures in the unlikely, but possible, event that we hit this from two projects simultaneously.
106108
-->
107-
<Touch Files="$(ToolsDir)Microsoft.DotNet.Build.Tasks.dll;$(NugetToolPath);$(DnuToolPath)" />
109+
<Touch Files="$(BuildToolsSemaphore)"
110+
ContinueOnError="WarnAndContinue"
111+
AlwaysCreate="true"
112+
ForceTouch="true" />
113+
114+
<Error Condition="'$(ErrorIfBuildToolsRestoredFromIndividualProject)'=='true'"
115+
Text="The build tools package was just restored and so we cannot continue the build of an individual project because targets from the build tools package were not able to be imported. Please retry the build the individual project again." />
108116
</Target>
109117

110118
<!-- Provide default targets which can be hooked onto or overridden as necessary -->

src/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFile.cs

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace System.IO.Compression
88
{
99
public static class ZipFile
1010
{
11+
// Per the .ZIP File Format Specification 4.4.17.1 all slashes should be forward slashes
12+
private const char c_pathSeparator = '/';
13+
1114
/// <summary>
1215
/// Opens a <code>ZipArchive</code> on the specified path for reading. The specified file is opened with <code>FileMode.Open</code>.
1316
/// </summary>
@@ -503,10 +506,7 @@ private static void DoCreateFromDirectory(String sourceDirectoryName, String des
503506
Int32 entryNameLength = file.FullName.Length - basePath.Length;
504507
Debug.Assert(entryNameLength > 0);
505508

506-
String entryName = file.FullName.Substring(basePath.Length, entryNameLength);
507-
508-
// Remove any leading slashes from the entry name:
509-
entryName = entryName.TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
509+
String entryName = EntryFromPath(file.FullName, basePath.Length, entryNameLength);
510510

511511
if (file is FileInfo)
512512
{
@@ -520,18 +520,52 @@ private static void DoCreateFromDirectory(String sourceDirectoryName, String des
520520
if (possiblyEmpty != null && IsDirEmpty(possiblyEmpty))
521521
{
522522
// FullName never returns a directory separator character on the end,
523-
// but Zip archives require it to specify an explicit directory:
524-
archive.CreateEntry(entryName + Path.DirectorySeparatorChar);
523+
// but Zip archives require it to specify an explicit directory:
524+
archive.CreateEntry(entryName + c_pathSeparator);
525525
}
526526
}
527527
} // foreach
528528

529529
// If no entries create an empty root directory entry:
530530
if (includeBaseDirectory && directoryIsEmpty)
531-
archive.CreateEntry(di.Name + Path.DirectorySeparatorChar);
531+
archive.CreateEntry(EntryFromPath(di.Name, 0, di.Name.Length) + c_pathSeparator);
532+
532533
} // using
533534
} // DoCreateFromDirectory
534535

536+
private static string EntryFromPath(string entry, int offset, int length)
537+
{
538+
Debug.Assert(length <= entry.Length - offset);
539+
540+
// Remove any leading slashes from the entry name:
541+
while (length > 0)
542+
{
543+
if (entry[offset] != Path.DirectorySeparatorChar &&
544+
entry[offset] != Path.AltDirectorySeparatorChar)
545+
break;
546+
547+
offset++;
548+
length--;
549+
}
550+
551+
if (length == 0)
552+
return String.Empty;
553+
554+
// create a mutable copy
555+
char[] chars = entry.ToCharArray(offset, length);
556+
557+
// '/' is a more broadly recognized directory separator on all platforms (eg: mac, linux)
558+
// We don't use Path.DirectorySeparatorChar or AltDirectorySeparatorChar because this is
559+
// explicitly trying to standardize to '/'
560+
for(int i = 0; i < chars.Length; i++)
561+
{
562+
if (chars[i] == Path.DirectorySeparatorChar || chars[i] == Path.AltDirectorySeparatorChar)
563+
chars[i] = c_pathSeparator;
564+
}
565+
566+
return new string(chars);
567+
}
568+
535569

536570
private static Boolean IsDirEmpty(DirectoryInfo possiblyEmptyDir)
537571
{

src/System.IO.Compression.ZipFile/tests/ZipFileConvenienceMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private static void SameExceptForBaseDir(string zipNoBaseDir, string zipBaseDir,
4949
{
5050
ZipArchiveEntry bEntry = b.Entries[bIdx++];
5151

52-
Assert.Equal(Path.Combine(Path.GetFileName(baseDir), aEntry.FullName), bEntry.FullName);
52+
Assert.Equal(Path.GetFileName(baseDir) + "/" + aEntry.FullName, bEntry.FullName);
5353
Assert.Equal(aEntry.Name, bEntry.Name);
5454
Assert.Equal(aEntry.Length, bEntry.Length);
5555
Assert.Equal(aEntry.CompressedLength, bEntry.CompressedLength);

src/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Error.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public static void FileSystemWatcher_Error_File()
6363
int internalBufferOperationCapacity = watcher.InternalBufferSize / (12 + 2 * (file.Path.Length + 1));
6464

6565
// generate enough file change events to overflow the buffer
66-
// 2x is an approximation that should force the overflow.
67-
for (int i = 1; i < internalBufferOperationCapacity * 2; i++)
66+
// 4x is an approximation that should force the overflow.
67+
for (int i = 1; i < internalBufferOperationCapacity * 4; i++)
6868
{
6969
File.SetLastWriteTime(file.Path, DateTime.Now + TimeSpan.FromSeconds(i));
7070
}

0 commit comments

Comments
 (0)