diff --git a/pkg/cmd/package/nuget/create/create.go b/pkg/cmd/package/nuget/create/create.go
index e7718d03..ec240799 100644
--- a/pkg/cmd/package/nuget/create/create.go
+++ b/pkg/cmd/package/nuget/create/create.go
@@ -16,6 +16,7 @@ import (
"github.com/OctopusDeploy/cli/pkg/surveyext"
"github.com/OctopusDeploy/cli/pkg/util"
"github.com/OctopusDeploy/cli/pkg/util/flag"
+ "github.com/google/uuid"
"github.com/spf13/cobra"
)
@@ -115,19 +116,37 @@ func createRun(cmd *cobra.Command, opts *NuPkgCreateOptions) error {
if shouldGenerateNuSpec(opts) {
defer func() {
if nuspecFilePath != "" {
- err := os.Remove(nuspecFilePath)
- if err != nil {
- panic(err)
- }
+ defer cleanupFile(nuspecFilePath)
}
}()
nuspecFilePath, err = GenerateNuSpec(opts)
if err != nil {
return err
}
- opts.Include.Value = append(opts.Include.Value, opts.Id.Value+".nuspec")
+ opts.Include.Value = append(opts.Include.Value, nuspecFilePath)
}
+ contentTypesFilePath, err := generateContentTypesFile(opts)
+ if err != nil {
+ return err
+ }
+ defer cleanupFile(contentTypesFilePath)
+ opts.Include.Value = append(opts.Include.Value, contentTypesFilePath)
+
+ corePropertiesFilePath, err := generateCorePropertiesFile(opts)
+ if err != nil {
+ return err
+ }
+ defer cleanupFile(corePropertiesFilePath)
+ opts.Include.Value = append(opts.Include.Value, corePropertiesFilePath)
+
+ relsFilePath, err := generateRelsFile(opts, nuspecFilePath, corePropertiesFilePath)
+ if err != nil {
+ return err
+ }
+ defer cleanupFile(relsFilePath)
+ opts.Include.Value = append(opts.Include.Value, relsFilePath)
+
pack.VerboseOut(opts.Writer, opts.Verbose.Value, "Packing \"%s\" version \"%s\"...\n", opts.Id.Value, opts.Version.Value)
outFilePath := pack.BuildOutFileName("nupkg", opts.Id.Value, opts.Version.Value)
@@ -325,3 +344,92 @@ func GenerateNuSpec(opts *NuPkgCreateOptions) (string, error) {
return filePath, file.Close()
}
+
+func generateContentTypesFile(opts *NuPkgCreateOptions) (string, error) {
+ filePath := filepath.Join(opts.BasePath.Value, "[Content_Types].xml")
+ var sb strings.Builder
+ sb.WriteString(`
+
+
+
+
+
+
+
+
+`)
+ file, err := os.Create(filePath)
+ if err != nil {
+ return "", err
+ }
+
+ _, err = file.WriteString(sb.String())
+ if err != nil {
+ return "", err
+ }
+
+ return filePath, file.Close()
+}
+
+func generateCorePropertiesFile(opts *NuPkgCreateOptions) (string, error) {
+ fileName := strings.Replace(uuid.New().String(), "-", "", -1) + ".psmdcp"
+ filePath := filepath.Join(opts.BasePath.Value, "package", "services", "metadata", "core-properties", fileName)
+ var sb strings.Builder
+ sb.WriteString(`
+
+ @
+ ` + opts.Description.Value + `
+ ` + opts.Id.Value + `
+ ` + opts.Version.Value + `
+
+ Octopus CLI
+`)
+ err := os.MkdirAll(filepath.Dir(filePath), 0770)
+ if err != nil {
+ return "", err
+ }
+ file, err := os.Create(filePath)
+ if err != nil {
+ return "", err
+ }
+
+ _, err = file.WriteString(sb.String())
+ if err != nil {
+ return "", err
+ }
+
+ return filePath, file.Close()
+}
+
+func generateRelsFile(opts *NuPkgCreateOptions, nuspecFilePath, corePropertiesFilePath string) (string, error) {
+ filePath := filepath.Join(opts.BasePath.Value, "_rels", ".rels")
+ var sb strings.Builder
+ sb.WriteString(`
+
+
+
+`)
+ err := os.MkdirAll(filepath.Dir(filePath), 0770)
+ if err != nil {
+ return "", err
+ }
+ file, err := os.Create(filePath)
+ if err != nil {
+ return "", err
+ }
+
+ _, err = file.WriteString(sb.String())
+ if err != nil {
+ return "", err
+ }
+
+ return filePath, file.Close()
+}
+
+func cleanupFile(filePath string) {
+ err := os.Remove(filePath)
+ if err != nil {
+ panic(err)
+ }
+}