Skip to content

Commit c707c3d

Browse files
authored
Trim down the main smoke-testNuGet.Config to generate the tarball version (#2159)
Instead of maintaining the duplicate, just generate it based on the main one. Fixes: #1669
1 parent 5dcc817 commit c707c3d

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

eng/SourceBuild.Tarball.targets

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
<Project>
22

3+
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="AddSourceToNuGetConfig" />
4+
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="RemoveInternetSourcesFromNuGetConfig" />
5+
36
<Target Name="PackSourceBuildTarball"
47
Condition="'$(PackSourceBuildTarball)' == 'true'"
58
DependsOnTargets="
69
GetTarballDirProps;
710
AddTarballSource;
811
AddTarballSourcelinkMetadata;
12+
GenerateTarballSmokeTestNuGetConfig;
913
AddTarballTools;
1014
AddTarballPackages;
1115
AddTarballExternalTarballs;
@@ -106,6 +110,23 @@
106110
DestinationFiles="@(ArtifactsGitDir -> '$(TarballSourceDir)%(RecursiveDir)%(Filename)%(Extension)')" />
107111
</Target>
108112

113+
<Target Name="GenerateTarballSmokeTestNuGetConfig">
114+
115+
<Copy
116+
SourceFiles="$(ProjectDir)smoke-testNuGet.Config"
117+
DestinationFiles="$(ProjectDir)artifacts\tarball-smoke-testNuGet.Config" />
118+
119+
<RemoveInternetSourcesFromNuGetConfig
120+
NuGetConfigFile="$(ProjectDir)artifacts\tarball-smoke-testNuGet.Config"
121+
OfflineBuild="false"
122+
RemoveFeedPrefixes="darc-pub-dotnet-" />
123+
124+
<AddSourceToNuGetConfig NuGetConfigFile="$(ProjectDir)artifacts\tarball-smoke-testNuGet.Config"
125+
SourceName="smoke-test feed"
126+
SourcePath="SMOKE_TEST_PACKAGE_FEED" />
127+
128+
</Target>
129+
109130
<Target Name="AddTarballTools">
110131
<ItemGroup>
111132
<TarballRootToolFile
@@ -166,13 +187,13 @@
166187
in it to generate a full set of smoke-test-prereqs. This isn't necessary in the tarball
167188
because we have those smoke-test-prereqs, but we hit authentication errors nonetheless. Copy
168189
a trimmed down nuget.config in this case.
169-
TODO: Automatically trim down the main nuget.config.
170190
-->
171191
<TarballCopyFile
172-
Condition="Exists('$(ProjectDir)support\tarball\smoke-testNuGet.Config')"
173-
Include="$(ProjectDir)support\tarball\smoke-testNuGet.Config"
192+
Condition="Exists('$(ProjectDir)artifacts\tarball-smoke-testNuGet.Config')"
193+
Include="$(ProjectDir)artifacts\tarball-smoke-testNuGet.Config"
174194
RelativeDestination="smoke-testNuGet.Config" />
175195

196+
176197
<!-- Setup package version props to include both source-built and running PackageVersions.props -->
177198
<TarballCopyFile
178199
Include="$(ProjectDir)support\tarball\PackageVersions.props"

support/tarball/smoke-testNuGet.Config

Lines changed: 0 additions & 10 deletions
This file was deleted.

tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/RemoveInternetSourcesFromNuGetConfig.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ public class RemoveInternetSourcesFromNuGetConfig : Task
3434
/// </summary>
3535
public string[] KeepFeedPrefixes { get; set; }
3636

37+
/// <summary>
38+
/// A list of prefix strings that make the task remove a package source unconditionally. For
39+
/// example, a source named 'darc-pub-dotnet-aspnetcore-e81033e' will be removed if the prefix
40+
/// 'darc-pub-dotnet-aspnetcore-' is in this list.
41+
/// </summary>
42+
public string[] RemoveFeedPrefixes { get; set; }
43+
3744
public override bool Execute()
3845
{
3946
XDocument d = XDocument.Load(NuGetConfigFile);
@@ -52,6 +59,13 @@ public override bool Execute()
5259
return true;
5360
}
5461

62+
if (RemoveFeedPrefixes
63+
?.Any(prefix => feedName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
64+
== true)
65+
{
66+
return false;
67+
}
68+
5569
string feedUrl = e.Attribute("value").Value;
5670
if (OfflineBuild)
5771
{

0 commit comments

Comments
 (0)