@@ -30,14 +30,16 @@ The initial error is:
3030)
3131
3232type DotnetCommand struct {
33- toolchainType dotnet.ToolchainType
34- subCommand string
35- argAndFlags []string
36- repoName string
37- solutionPath string
38- useNugetV2 bool
39- buildConfiguration * commonBuild.BuildConfiguration
40- serverDetails * config.ServerDetails
33+ toolchainType dotnet.ToolchainType
34+ subCommand string
35+ argAndFlags []string
36+ repoName string
37+ solutionPath string
38+ useNugetV2 bool
39+ // By default, package sources are required to use HTTPS. This option allows sources to use HTTP.
40+ allowInsecureConnections bool
41+ buildConfiguration * commonBuild.BuildConfiguration
42+ serverDetails * config.ServerDetails
4143}
4244
4345func (dc * DotnetCommand ) SetServerDetails (serverDetails * config.ServerDetails ) * DotnetCommand {
@@ -70,6 +72,11 @@ func (dc *DotnetCommand) SetUseNugetV2(useNugetV2 bool) *DotnetCommand {
7072 return dc
7173}
7274
75+ func (dc * DotnetCommand ) SetAllowInsecureConnections (allowInsecureConnections bool ) * DotnetCommand {
76+ dc .allowInsecureConnections = allowInsecureConnections
77+ return dc
78+ }
79+
7380func (dc * DotnetCommand ) SetArgAndFlags (argAndFlags []string ) * DotnetCommand {
7481 dc .argAndFlags = argAndFlags
7582 return dc
@@ -242,7 +249,7 @@ func (dc *DotnetCommand) prepareConfigFileIfNeeded() (cleanup func() error, err
242249 return fileutils .RemoveTempDir (tempDirPath )
243250 }
244251
245- configFile , err := InitNewConfig (tempDirPath , dc .repoName , dc .serverDetails , dc .useNugetV2 )
252+ configFile , err := InitNewConfig (tempDirPath , dc .repoName , dc .serverDetails , dc .useNugetV2 , dc . allowInsecureConnections )
246253 if err == nil {
247254 dc .argAndFlags = append (dc .argAndFlags , dc .GetToolchain ().GetTypeFlagPrefix ()+ "configfile" , configFile .Name ())
248255 }
@@ -269,7 +276,7 @@ func getFlagValueIfExists(cmdFlag string, argAndFlags []string) (string, error)
269276}
270277
271278// InitNewConfig is used when neither of the flags were provided, and we need to init our own config.
272- func InitNewConfig (configDirPath , repoName string , server * config.ServerDetails , useNugetV2 bool ) (configFile * os.File , err error ) {
279+ func InitNewConfig (configDirPath , repoName string , server * config.ServerDetails , useNugetV2 , allowInsecureConnections bool ) (configFile * os.File , err error ) {
273280 // Initializing a new NuGet config file that NuGet will use into a temp file
274281 configFile , err = os .CreateTemp (configDirPath , configFilePattern )
275282 if errorutils .CheckError (err ) != nil {
@@ -283,12 +290,12 @@ func InitNewConfig(configDirPath, repoName string, server *config.ServerDetails,
283290 // We would prefer to write the NuGet configuration using the `nuget add source` command,
284291 // but the NuGet configuration utility doesn't currently allow setting protocolVersion.
285292 // Until that is supported, the templated method must be used.
286- err = addSourceToNugetTemplate (configFile , server , useNugetV2 , repoName )
293+ err = addSourceToNugetTemplate (configFile , server , useNugetV2 , repoName , allowInsecureConnections )
287294 return
288295}
289296
290297// Adds a source to the nuget config template
291- func addSourceToNugetTemplate (configFile * os.File , server * config.ServerDetails , useNugetV2 bool , repoName string ) error {
298+ func addSourceToNugetTemplate (configFile * os.File , server * config.ServerDetails , useNugetV2 bool , repoName string , allowInsecureConnections bool ) error {
292299 sourceUrl , user , password , err := GetSourceDetails (server , repoName , useNugetV2 )
293300 if err != nil {
294301 return err
@@ -301,7 +308,7 @@ func addSourceToNugetTemplate(configFile *os.File, server *config.ServerDetails,
301308 }
302309
303310 // Format the templates
304- _ , err = fmt .Fprintf (configFile , dotnet .ConfigFileFormat , sourceUrl , protoVer , user , password )
311+ _ , err = fmt .Fprintf (configFile , dotnet .ConfigFileFormat , sourceUrl , protoVer , allowInsecureConnections , user , password )
305312 return err
306313}
307314
0 commit comments