Skip to content

Commit 328e021

Browse files
Dependencies: run alias version-props transform during CI prepare
`DependencySource.CreateRestoredDependency(BuildContext, ParametrizedDependency, ...)` is called from `VersionFile.TryRead` early in PrepareCommand, before `DependenciesHelper.ResolveRestoredDependencies` (the existing transform site) runs. For an aliased dep, TeamCity restores `{Name}.version.props` to `dependencies/{Key}/`; Core then expects `{Key}.version.props` and crashed with FileNotFoundException. Run the transform here so the CI prepare step finds the file under the alias name.
1 parent 25228a6 commit 328e021

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

src/PostSharp.Engineering.BuildTools/Dependencies/Model/DependencySource.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,30 @@ public static DependencySource CreateRestoredDependency(
5656
BuildContext context,
5757
ParametrizedDependency dependency,
5858
DependencyConfigurationOrigin origin )
59-
=> CreateRestoredDependencyCore( context, dependency.Key, dependency.KeyWithoutDot, origin );
59+
{
60+
// For aliased deps in CI mode, TeamCity restores the producer's {Name}.version.props to dependencies/{Key}/.
61+
// The on-disk file is {Name}.version.props (producer's name) but Core expects {Key}.version.props (alias).
62+
// The full fetch path runs this transform via DependenciesHelper.ResolveRestoredDependencies, but VersionFile.TryRead
63+
// (called from PrepareCommand) reaches Core directly without going through fetch. Run the transform here so the
64+
// CI prepare step doesn't crash before the artifact-aware code path even gets a chance.
65+
if ( dependency.Alias != null )
66+
{
67+
var aliasDirectory = TeamCityHelper.GetRestoredDependencyDirectory( context.RepoDirectory, dependency.Key );
68+
var producerVersionPropsPath = Path.Combine( aliasDirectory, dependency.Definition.Name + ".version.props" );
69+
var aliasedVersionPropsPath = Path.Combine( aliasDirectory, dependency.Key + ".version.props" );
70+
71+
if ( File.Exists( producerVersionPropsPath ) )
72+
{
73+
DependenciesHelper.TransformVersionPropsForAlias(
74+
producerVersionPropsPath,
75+
aliasedVersionPropsPath,
76+
dependency.Definition.NameWithoutDot,
77+
dependency.KeyWithoutDot );
78+
}
79+
}
80+
81+
return CreateRestoredDependencyCore( context, dependency.Key, dependency.KeyWithoutDot, origin );
82+
}
6083

6184
/// <summary>
6285
/// Creates a <see cref="DependencySource"/> that represents a build server artifact dependency that has been restored,

0 commit comments

Comments
 (0)