1
- import { mkdir , readFile , writeFile } from "fs/promises" ;
1
+ import { access , mkdir , readFile , writeFile } from "fs/promises" ;
2
2
import { template } from "lodash-es" ;
3
3
import path from "path" ;
4
4
@@ -9,6 +9,7 @@ import { loggingExeca } from "@fern-api/logging-execa";
9
9
10
10
import { AsIsFiles } from "../AsIs" ;
11
11
import { AbstractCsharpGeneratorContext } from "../context/AbstractCsharpGeneratorContext" ;
12
+ import { findDotnetToolPath } from "../findDotNetToolPath" ;
12
13
import { CSharpFile } from "./CSharpFile" ;
13
14
14
15
const SRC_DIRECTORY_NAME = "src" ;
@@ -162,12 +163,10 @@ export class CsharpProject extends AbstractProject<AbstractCsharpGeneratorContex
162
163
await this . createPublicCoreDirectory ( { absolutePathToProjectDirectory } ) ;
163
164
164
165
try {
165
- await loggingExeca ( this . context . logger , "dotnet" , [ "csharpier" , "." ] , {
166
+ const csharpier = findDotnetToolPath ( "dotnet-csharpier" ) ;
167
+ await loggingExeca ( this . context . logger , csharpier , [ "--fast" , "--no-msbuild-check" , "." ] , {
166
168
doNotPipeOutput : true ,
167
- cwd : absolutePathToSrcDirectory ,
168
- env : {
169
- DOTNET_CLI_TELEMETRY_OPTOUT : "1"
170
- }
169
+ cwd : absolutePathToSrcDirectory
171
170
} ) ;
172
171
} catch ( error ) {
173
172
this . context . logger . warn ( "csharpier command failed, continuing without formatting." ) ;
@@ -179,10 +178,12 @@ export class CsharpProject extends AbstractProject<AbstractCsharpGeneratorContex
179
178
} : {
180
179
absolutePathToSrcDirectory : AbsoluteFilePath ;
181
180
} ) : Promise < AbsoluteFilePath > {
182
- await loggingExeca ( this . context . logger , "dotnet" , [ "new" , "sln" , "-n" , this . name ] , {
183
- doNotPipeOutput : true ,
184
- cwd : absolutePathToSrcDirectory
185
- } ) ;
181
+ await access ( path . join ( absolutePathToSrcDirectory , `${ this . name } .sln` ) ) . catch ( ( ) =>
182
+ loggingExeca ( this . context . logger , "dotnet" , [ "new" , "sln" , "-n" , this . name , "--no-update-check" ] , {
183
+ doNotPipeOutput : true ,
184
+ cwd : absolutePathToSrcDirectory
185
+ } )
186
+ ) ;
186
187
187
188
const absolutePathToProjectDirectory = join ( absolutePathToSrcDirectory , RelativeFilePath . of ( this . name ) ) ;
188
189
this . context . logger . debug ( `mkdir ${ absolutePathToProjectDirectory } ` ) ;
0 commit comments