Skip to content

Commit 19caf73

Browse files
committed
Explicitly use invariant culture during parsing
1 parent 8375919 commit 19caf73

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/StaticWebAssetsSdk/Tasks/Data/StaticWebAsset.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ private static StaticWebAsset FromTaskItemCore(ITaskItem item) =>
220220
CopyToPublishDirectory = item.GetMetadata(nameof(CopyToPublishDirectory)),
221221
OriginalItemSpec = item.GetMetadata(nameof(OriginalItemSpec)),
222222
FileLength = item.GetMetadata("FileLength") is string fileLengthString &&
223-
long.TryParse(fileLengthString, out var fileLength) ? fileLength : -1,
223+
long.TryParse(fileLengthString, NumberStyles.Integer, CultureInfo.InvariantCulture, out var fileLength) ? fileLength : -1,
224224
LastWriteTime = item.GetMetadata("LastWriteTime") is string lastWriteTimeString &&
225-
DateTimeOffset.TryParse(lastWriteTimeString, out var lastWriteTime) ? lastWriteTime : DateTimeOffset.MinValue
225+
DateTimeOffset.TryParse(lastWriteTimeString, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out var lastWriteTime) ? lastWriteTime : DateTimeOffset.MinValue
226226
};
227227

228228
public void ApplyDefaults()
@@ -485,6 +485,13 @@ public void Normalize()
485485
BasePath = Normalize(BasePath);
486486
RelativePath = Normalize(RelativePath, allowEmpyPath: true);
487487
RelatedAsset = !string.IsNullOrEmpty(RelatedAsset) ? Path.GetFullPath(RelatedAsset) : RelatedAsset;
488+
489+
if (FileLength < 0 || LastWriteTime == DateTimeOffset.MinValue)
490+
{
491+
var file = ResolveFile(Identity, OriginalItemSpec);
492+
FileLength = file.Length;
493+
LastWriteTime = file.LastWriteTimeUtc;
494+
}
488495
}
489496

490497
// Normalizes the given path to a content root path in the way we expect it:

0 commit comments

Comments
 (0)