-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
607 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="xunit.runner.console" version="2.1.0" /> | ||
<package id="MicroBuild.Core" version="0.3.0" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" DefaultTargets="AfterBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="..\packages\MicroBuild.Core.0.3.0\build\MicroBuild.Core.props" Condition="Exists('..\packages\MicroBuild.Core.0.3.0\build\MicroBuild.Core.props')" /> | ||
|
||
<PropertyGroup> | ||
<RepositoryRootDirectory>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\</RepositoryRootDirectory> | ||
<IntermediateOutputPath>$(RepositoryRootDirectory)artifacts\sign\obj\</IntermediateOutputPath> | ||
<OutDir>$(RepositoryRootDirectory)</OutDir> | ||
<SignTargetsDependOn>GetOutputNupkgs</SignTargetsDependOn> | ||
</PropertyGroup> | ||
|
||
<Target Name="GetOutputNupkgs"> | ||
<ItemGroup> | ||
<FilesToSign Include="$(RepositoryRootDirectory)artifacts\*.nupkg"> | ||
<Authenticode>NuGet</Authenticode> | ||
</FilesToSign> | ||
</ItemGroup> | ||
<Message Text="Files to sign:%0A@(FilesToSign, '%0A')" Importance="High" /> | ||
</Target> | ||
|
||
<Target Name="AfterBuild" DependsOnTargets="$(SignTargetsDependOn)"/> | ||
|
||
<Import Project="..\packages\MicroBuild.Core.0.3.0\build\MicroBuild.Core.targets" Condition="Exists('..\packages\MicroBuild.Core.0.3.0\build\MicroBuild.Core.targets')" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.IO; | ||
|
||
namespace NuGet.Server.Core.Infrastructure | ||
{ | ||
public static class KnownPathUtility | ||
{ | ||
/// <summary> | ||
/// Determines if a relative file path could have been generated by <see cref="ExpandedPackageRepository"/>. | ||
/// The path is assumed to be relative to the base of the package directory. | ||
/// </summary> | ||
/// <param name="path">The file path to parse.</param> | ||
/// <param name="id">The package ID found.</param> | ||
/// <param name="version">The package version found.</param> | ||
/// <returns>True if the file name is known.</returns> | ||
public static bool TryParseFileName(string path, out string id, out SemanticVersion version) | ||
{ | ||
id = null; | ||
version = null; | ||
|
||
if (path == null || Path.IsPathRooted(path)) | ||
{ | ||
return false; | ||
} | ||
|
||
var pathPieces = path.Split(Path.DirectorySeparatorChar); | ||
if (pathPieces.Length != 3) // {id}\{version}\{file name} | ||
{ | ||
return false; | ||
} | ||
|
||
id = pathPieces[pathPieces.Length - 3]; | ||
var unparsedVersion = pathPieces[pathPieces.Length - 2]; | ||
var fileName = pathPieces[pathPieces.Length - 1]; | ||
|
||
if (!SemanticVersion.TryParse(unparsedVersion, out version) | ||
|| version.ToNormalizedString() != unparsedVersion) | ||
{ | ||
return false; | ||
} | ||
|
||
string expectedFileName; | ||
if (fileName.EndsWith(NuGet.Constants.PackageExtension)) | ||
{ | ||
expectedFileName = $"{id}.{version}{NuGet.Constants.PackageExtension}"; | ||
} | ||
else if (fileName.EndsWith(NuGet.Constants.HashFileExtension)) | ||
{ | ||
expectedFileName = $"{id}.{version}{NuGet.Constants.HashFileExtension}"; | ||
} | ||
else if (fileName.EndsWith(NuGet.Constants.ManifestExtension)) | ||
{ | ||
expectedFileName = $"{id}{NuGet.Constants.ManifestExtension}"; | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
|
||
return expectedFileName == fileName; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.