@@ -48,6 +48,8 @@ public async Task<Package> RunAsync(CancellationToken cancellationToken)
4848 . BuildAsync ( cancellationToken : cancellationToken ) . EnsureSuccess ( ) ;
4949
5050 var targetPackage = Path . Combine ( packagesDirectory , $ "{ ProjectName } .{ packageVersion } .nupkg") ;
51+ await SmokeTestTemplatePackageAsync ( targetPackage , cancellationToken ) ;
52+
5153 artifactsWriter . PublishArtifact ( $ "{ targetPackage } => .") ;
5254
5355 if ( string . IsNullOrWhiteSpace ( settings . NuGetKey ) )
@@ -70,6 +72,68 @@ public async Task<Package> RunAsync(CancellationToken cancellationToken)
7072 }
7173 }
7274
75+ private async Task SmokeTestTemplatePackageAsync ( string packagePath , CancellationToken cancellationToken )
76+ {
77+ Summary ( "Smoke testing template package " , packagePath . WithColor ( Color . Details ) ) ;
78+
79+ var tempDirectory = env . GetPath ( PathType . TempDirectory ) ;
80+ var hiveDirectory = Path . Combine ( tempDirectory , "hive" ) ;
81+ var outputDirectory = Path . Combine ( tempDirectory , "out" ) ;
82+ var consoleAppDirectory = Path . Combine ( outputDirectory , "SmokeConsole" ) ;
83+ var classLibraryDirectory = Path . Combine ( outputDirectory , "SmokeLib" ) ;
84+
85+ try
86+ {
87+ Directory . CreateDirectory ( hiveDirectory ) ;
88+ Directory . CreateDirectory ( outputDirectory ) ;
89+
90+ await new DotNetNewInstall ( )
91+ . WithPackage ( Path . GetFullPath ( packagePath ) )
92+ . AddArgs ( "--debug:custom-hive" , hiveDirectory )
93+ . WithShortName ( "installing the template package into a custom hive" )
94+ . RunAsync ( cancellationToken : cancellationToken ) . EnsureSuccess ( ) ;
95+
96+ await CreateAndBuildTemplateProjectAsync ( "di" , "SmokeConsole" , consoleAppDirectory , hiveDirectory , cancellationToken ) ;
97+ await CreateAndBuildTemplateProjectAsync ( "dilib" , "SmokeLib" , classLibraryDirectory , hiveDirectory , cancellationToken ) ;
98+ }
99+ finally
100+ {
101+ if ( Directory . Exists ( tempDirectory ) )
102+ {
103+ Directory . Delete ( tempDirectory , true ) ;
104+ }
105+ }
106+ }
107+
108+ private static async Task CreateAndBuildTemplateProjectAsync (
109+ string templateName ,
110+ string projectName ,
111+ string outputDirectory ,
112+ string hiveDirectory ,
113+ CancellationToken cancellationToken )
114+ {
115+ await new DotNetNew ( )
116+ . WithTemplateName ( templateName )
117+ . WithName ( projectName )
118+ . WithOutput ( outputDirectory )
119+ . WithForce ( true )
120+ . AddArgs ( "--debug:custom-hive" , hiveDirectory )
121+ . WithShortName ( $ "creating a project from the { templateName } template")
122+ . RunAsync ( cancellationToken : cancellationToken ) . EnsureSuccess ( ) ;
123+
124+ var guidelinesPath = Path . Combine ( outputDirectory , ".junie" , "guidelines.md" ) ;
125+ if ( File . Exists ( guidelinesPath ) )
126+ {
127+ Error ( $ "The generated project contains unexpected file: { guidelinesPath } ") ;
128+ throw new InvalidOperationException ( $ "The generated project contains unexpected file: { guidelinesPath } ") ;
129+ }
130+
131+ await new DotNetBuild ( )
132+ . WithProject ( Path . Combine ( outputDirectory , $ "{ projectName } .csproj") )
133+ . WithShortName ( $ "building the project from the { templateName } template")
134+ . RunAsync ( cancellationToken : cancellationToken ) . EnsureSuccess ( ) ;
135+ }
136+
73137 private static async Task UpdateJsonFileWithVersion (
74138 IEnumerable < string > jsonFiles ,
75139 string targetStr ,
0 commit comments