Skip to content

Commit

Permalink
Trim down the main smoke-testNuGet.Config to generate the tarball ver…
Browse files Browse the repository at this point in the history
…sion (#2159)

Instead of maintaining the duplicate, just generate it based on the main
one.

Fixes: #1669
  • Loading branch information
omajid authored May 28, 2021
1 parent 5dcc817 commit c707c3d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
27 changes: 24 additions & 3 deletions eng/SourceBuild.Tarball.targets
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<Project>

<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="AddSourceToNuGetConfig" />
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="RemoveInternetSourcesFromNuGetConfig" />

<Target Name="PackSourceBuildTarball"
Condition="'$(PackSourceBuildTarball)' == 'true'"
DependsOnTargets="
GetTarballDirProps;
AddTarballSource;
AddTarballSourcelinkMetadata;
GenerateTarballSmokeTestNuGetConfig;
AddTarballTools;
AddTarballPackages;
AddTarballExternalTarballs;
Expand Down Expand Up @@ -106,6 +110,23 @@
DestinationFiles="@(ArtifactsGitDir -> '$(TarballSourceDir)%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>

<Target Name="GenerateTarballSmokeTestNuGetConfig">

<Copy
SourceFiles="$(ProjectDir)smoke-testNuGet.Config"
DestinationFiles="$(ProjectDir)artifacts\tarball-smoke-testNuGet.Config" />

<RemoveInternetSourcesFromNuGetConfig
NuGetConfigFile="$(ProjectDir)artifacts\tarball-smoke-testNuGet.Config"
OfflineBuild="false"
RemoveFeedPrefixes="darc-pub-dotnet-" />

<AddSourceToNuGetConfig NuGetConfigFile="$(ProjectDir)artifacts\tarball-smoke-testNuGet.Config"
SourceName="smoke-test feed"
SourcePath="SMOKE_TEST_PACKAGE_FEED" />

</Target>

<Target Name="AddTarballTools">
<ItemGroup>
<TarballRootToolFile
Expand Down Expand Up @@ -166,13 +187,13 @@
in it to generate a full set of smoke-test-prereqs. This isn't necessary in the tarball
because we have those smoke-test-prereqs, but we hit authentication errors nonetheless. Copy
a trimmed down nuget.config in this case.
TODO: Automatically trim down the main nuget.config.
-->
<TarballCopyFile
Condition="Exists('$(ProjectDir)support\tarball\smoke-testNuGet.Config')"
Include="$(ProjectDir)support\tarball\smoke-testNuGet.Config"
Condition="Exists('$(ProjectDir)artifacts\tarball-smoke-testNuGet.Config')"
Include="$(ProjectDir)artifacts\tarball-smoke-testNuGet.Config"
RelativeDestination="smoke-testNuGet.Config" />


<!-- Setup package version props to include both source-built and running PackageVersions.props -->
<TarballCopyFile
Include="$(ProjectDir)support\tarball\PackageVersions.props"
Expand Down
10 changes: 0 additions & 10 deletions support/tarball/smoke-testNuGet.Config

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public class RemoveInternetSourcesFromNuGetConfig : Task
/// </summary>
public string[] KeepFeedPrefixes { get; set; }

/// <summary>
/// A list of prefix strings that make the task remove a package source unconditionally. For
/// example, a source named 'darc-pub-dotnet-aspnetcore-e81033e' will be removed if the prefix
/// 'darc-pub-dotnet-aspnetcore-' is in this list.
/// </summary>
public string[] RemoveFeedPrefixes { get; set; }

public override bool Execute()
{
XDocument d = XDocument.Load(NuGetConfigFile);
Expand All @@ -52,6 +59,13 @@ public override bool Execute()
return true;
}

if (RemoveFeedPrefixes
?.Any(prefix => feedName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
== true)
{
return false;
}

string feedUrl = e.Attribute("value").Value;
if (OfflineBuild)
{
Expand Down

0 comments on commit c707c3d

Please sign in to comment.