Skip to content

Commit 59ddd69

Browse files
gfraiteurclaude
andcommitted
Add PrepareDependenciesCommand and normalize line endings.
Add new PrepareDependenciesCommand that generates dependency files with current settings. Also normalize line endings in AppExtensions.cs and SetDependenciesCommand.cs. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 8d246cb commit 59ddd69

File tree

3 files changed

+124
-99
lines changed

3 files changed

+124
-99
lines changed

src/PostSharp.Engineering.BuildTools/AppExtensions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ internal static void AddCommands( this CommandApp app, Product product )
133133
dependencies.AddCommand<UpdateEngineeringCommand>( "update-eng" )
134134
.WithData( data )
135135
.WithDescription( "Updates PostSharp.Engineering in global.json and Versions.props." );
136+
137+
dependencies.AddCommand<PrepareDependenciesCommand>( "prepare" )
138+
.WithData( data )
139+
.WithDescription( "Generates the dependency files with the current settings." );
136140
} );
137141

138142
root.AddBranch(
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using JetBrains.Annotations;
2+
using PostSharp.Engineering.BuildTools.Build;
3+
using PostSharp.Engineering.BuildTools.Build.Files;
4+
using PostSharp.Engineering.BuildTools.Dependencies.Model;
5+
6+
namespace PostSharp.Engineering.BuildTools.Dependencies;
7+
8+
/// <summary>
9+
/// Generates the dependency files with the current settings.
10+
/// </summary>
11+
[UsedImplicitly]
12+
internal class PrepareDependenciesCommand : ConfigureDependenciesCommand<ConfigureDependenciesCommandSettings>
13+
{
14+
protected override bool ConfigureDependency(
15+
BuildContext context,
16+
DependenciesConfigurationFile dependenciesConfigurationFile,
17+
DependencyDefinition dependencyDefinition,
18+
ConfigureDependenciesCommandSettings settings,
19+
DependenciesConfigurationFile defaultDependenciesConfigurationFile )
20+
=> true;
21+
}
Lines changed: 99 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,100 @@
1-
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
2-
3-
using JetBrains.Annotations;
4-
using PostSharp.Engineering.BuildTools.Build;
5-
using PostSharp.Engineering.BuildTools.Build.Files;
6-
using PostSharp.Engineering.BuildTools.Dependencies.Model;
7-
using System;
8-
9-
namespace PostSharp.Engineering.BuildTools.Dependencies
10-
{
11-
/// <summary>
12-
/// Sets the source of a dependency to <see cref="DependencySourceKind.Local"/>, <see cref="DependencySourceKind.BuildServer"/>
13-
/// or <see cref="DependencySourceKind.Feed"/>.
14-
/// </summary>
15-
[UsedImplicitly]
16-
internal class SetDependenciesCommand : ConfigureDependenciesCommand<SetDependenciesCommandSettings>
17-
{
18-
protected override bool ConfigureDependency(
19-
BuildContext context,
20-
DependenciesConfigurationFile dependenciesConfigurationFile,
21-
DependencyDefinition dependencyDefinition,
22-
SetDependenciesCommandSettings settings,
23-
DependenciesConfigurationFile defaultDependenciesConfigurationFile )
24-
{
25-
DependencySource dependencySource;
26-
27-
switch ( settings.Source )
28-
{
29-
case DependencySourceKind.Local:
30-
dependencySource = DependencySource.CreateLocalDependency( DependencyConfigurationOrigin.Override, settings.LocalPath );
31-
32-
break;
33-
34-
case DependencySourceKind.RestoredDependency:
35-
if ( settings.SimulateContinuousIntegration )
36-
{
37-
#pragma warning disable CS0618
38-
39-
// TODO: What to use instead of settings.BuildConfiguration?
40-
if ( settings.BuildConfiguration == null )
41-
42-
{
43-
context.Console.WriteError( $"-c|--configuration is mandatory with --ci." );
44-
45-
return false;
46-
}
47-
48-
#pragma warning restore CS0618
49-
}
50-
51-
#pragma warning disable CS0618
52-
53-
// TODO: What to use instead of settings.BuildConfiguration?
54-
dependencySource = DependencySource.CreateRestoredDependency(
55-
context,
56-
dependencyDefinition,
57-
DependencyConfigurationOrigin.Override );
58-
#pragma warning restore CS0618
59-
60-
break;
61-
62-
case DependencySourceKind.Feed:
63-
dependencySource = DependencySource.CreateFeed( null, DependencyConfigurationOrigin.Override );
64-
65-
break;
66-
67-
case DependencySourceKind.BuildServer:
68-
ICiBuildSpec buildSpec;
69-
70-
if ( settings.Branch != null )
71-
{
72-
buildSpec = new CiLatestBuildOfBranch( settings.Branch );
73-
}
74-
else if ( settings.BuildNumber != null )
75-
{
76-
buildSpec = new CiBuildId( settings.BuildNumber.Value, settings.CiBuildTypeId );
77-
}
78-
else
79-
{
80-
context.Console.WriteError( "Either the --branch or --buildNumber parameter should be specified." );
81-
82-
return false;
83-
}
84-
85-
dependencySource = DependencySource.CreateBuildServerSource(
86-
buildSpec,
87-
DependencyConfigurationOrigin.Override );
88-
89-
break;
90-
91-
default:
92-
throw new InvalidOperationException();
93-
}
94-
95-
dependenciesConfigurationFile.Dependencies[dependencyDefinition.Name] = dependencySource;
96-
97-
return true;
98-
}
99-
}
1+
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
2+
3+
using JetBrains.Annotations;
4+
using PostSharp.Engineering.BuildTools.Build;
5+
using PostSharp.Engineering.BuildTools.Build.Files;
6+
using PostSharp.Engineering.BuildTools.Dependencies.Model;
7+
using System;
8+
9+
namespace PostSharp.Engineering.BuildTools.Dependencies
10+
{
11+
/// <summary>
12+
/// Sets the source of a dependency to <see cref="DependencySourceKind.Local"/>, <see cref="DependencySourceKind.BuildServer"/>
13+
/// or <see cref="DependencySourceKind.Feed"/>.
14+
/// </summary>
15+
[UsedImplicitly]
16+
internal class SetDependenciesCommand : ConfigureDependenciesCommand<SetDependenciesCommandSettings>
17+
{
18+
protected override bool ConfigureDependency(
19+
BuildContext context,
20+
DependenciesConfigurationFile dependenciesConfigurationFile,
21+
DependencyDefinition dependencyDefinition,
22+
SetDependenciesCommandSettings settings,
23+
DependenciesConfigurationFile defaultDependenciesConfigurationFile )
24+
{
25+
DependencySource dependencySource;
26+
27+
switch ( settings.Source )
28+
{
29+
case DependencySourceKind.Local:
30+
dependencySource = DependencySource.CreateLocalDependency( DependencyConfigurationOrigin.Override, settings.LocalPath );
31+
32+
break;
33+
34+
case DependencySourceKind.RestoredDependency:
35+
if ( settings.SimulateContinuousIntegration )
36+
{
37+
#pragma warning disable CS0618
38+
39+
// TODO: What to use instead of settings.BuildConfiguration?
40+
if ( settings.BuildConfiguration == null )
41+
42+
{
43+
context.Console.WriteError( $"-c|--configuration is mandatory with --ci." );
44+
45+
return false;
46+
}
47+
48+
#pragma warning restore CS0618
49+
}
50+
51+
#pragma warning disable CS0618
52+
53+
// TODO: What to use instead of settings.BuildConfiguration?
54+
dependencySource = DependencySource.CreateRestoredDependency(
55+
context,
56+
dependencyDefinition,
57+
DependencyConfigurationOrigin.Override );
58+
#pragma warning restore CS0618
59+
60+
break;
61+
62+
case DependencySourceKind.Feed:
63+
dependencySource = DependencySource.CreateFeed( null, DependencyConfigurationOrigin.Override );
64+
65+
break;
66+
67+
case DependencySourceKind.BuildServer:
68+
ICiBuildSpec buildSpec;
69+
70+
if ( settings.Branch != null )
71+
{
72+
buildSpec = new CiLatestBuildOfBranch( settings.Branch );
73+
}
74+
else if ( settings.BuildNumber != null )
75+
{
76+
buildSpec = new CiBuildId( settings.BuildNumber.Value, settings.CiBuildTypeId );
77+
}
78+
else
79+
{
80+
context.Console.WriteError( "Either the --branch or --buildNumber parameter should be specified." );
81+
82+
return false;
83+
}
84+
85+
dependencySource = DependencySource.CreateBuildServerSource(
86+
buildSpec,
87+
DependencyConfigurationOrigin.Override );
88+
89+
break;
90+
91+
default:
92+
throw new InvalidOperationException();
93+
}
94+
95+
dependenciesConfigurationFile.Dependencies[dependencyDefinition.Name] = dependencySource;
96+
97+
return true;
98+
}
99+
}
100100
}

0 commit comments

Comments
 (0)