@@ -13,8 +13,7 @@ TEST_PROJECT = ./Tests/VaultSharp.Extensions.Configuration.Test/VaultSharp.E
13
13
PROJECT_TO_PUBLISH = ./Source/VaultSharp.Extensions.Configuration/VaultSharp.Extensions.Configuration.csproj
14
14
15
15
# Output Directories
16
- PUBLISH_DIR = ./publish
17
- PUBLISH_APP_DIR = $(PUBLISH_DIR ) /App # Specific dir for the published app
16
+ PUBLISH_DIR = .\publish
18
17
19
18
# Version Info (Consider making this dynamic, e.g., from git tag or a file)
20
19
VERSION = 1.0.0
@@ -30,17 +29,35 @@ DOTNET = dotnet
30
29
# Shell settings (use bash for more features if needed)
31
30
SHELL = /bin/sh
32
31
32
+ # -----------------------------------------------------------------------------
33
+ # Cross-platform Shell Helper
34
+ # -----------------------------------------------------------------------------
35
+ # Use 'pwsh' if available, otherwise fallback to 'powershell' on Windows
36
+ ifeq ($(OS ) ,Windows_NT)
37
+ SHELL := pwsh.exe
38
+ POWERSHELL := pwsh.exe
39
+ MD = if (!(Test-Path '$(PUBLISH_DIR)')) { New-Item -ItemType Directory -Path '$(PUBLISH_DIR)' | Out-Null }
40
+ RM = if (Test-Path '$(PUBLISH_DIR)') { Remove-Item -Recurse -Force '$(PUBLISH_DIR)' }
41
+ LS = Test-Path "$(PUBLISH_DIR)\*.nupkg"
42
+ else
43
+ SHELL := /bin/bash
44
+ POWERSHELL := pwsh
45
+ MD = mkdir -p $(PUBLISH_DIR)
46
+ RM = rm -rf $(PUBLISH_DIR)
47
+ LS = ls $(PUBLISH_DIR)/*.nupkg 1> /dev/null 2>&1
48
+ endif
49
+
33
50
# -----------------------------------------------------------------------------
34
51
# Phony Targets (Targets that don't represent files)
35
52
# -----------------------------------------------------------------------------
36
- .PHONY : all Default Clean Restore Build Test Pack Publish Push help
53
+ .PHONY : all Default Clean Restore Build Test Pack Push help
37
54
38
55
# -----------------------------------------------------------------------------
39
56
# Default Target
40
57
# -----------------------------------------------------------------------------
41
58
# The first target is the default if none is specified on the command line.
42
59
# Maps to Cake's "Default" task which depends on "Publish".
43
- Default : Publish
60
+ Default : Pack
44
61
45
62
all : Default # Common alias for the main default action
46
63
@@ -89,32 +106,21 @@ Test: Build
89
106
# Depends on Build
90
107
Pack : Build
91
108
@echo " --- Packing NuGet Packages (Version: $( VERSION) ) ---"
92
- # Ensure publish dir exists for output
93
- mkdir -p $(PUBLISH_DIR )
109
+ $(DOTNET ) --version > /dev/null 2>&1 && (mkdir -p $( PUBLISH_DIR) ) || (powershell -Command " if (!(Test-Path '$( PUBLISH_DIR) ')) { New-Item -ItemType Directory -Path '$( PUBLISH_DIR) ' | Out-Null }" )
94
110
$(DOTNET ) pack $(SOLUTION ) --configuration $(CONFIGURATION ) --no-build --no-restore -o $(PUBLISH_DIR ) /p:PackageVersion=$(VERSION ) /p:Version=$(VERSION )
95
111
@echo " Packaging complete. Packages in $( PUBLISH_DIR) "
96
112
97
- # Publish the application
98
- # Depends on Test (ensures tests pass before publishing)
99
- # Might also depend on Pack if publish consumes packed artifacts, but typically depends on Build/Test.
100
- Publish : Test
101
- @echo " --- Publishing Application (Version: $( VERSION) ) ---"
102
- # Ensure publish app dir exists
103
- mkdir -p $(PUBLISH_APP_DIR )
104
- $(DOTNET ) publish $(PROJECT_TO_PUBLISH ) --configuration $(CONFIGURATION ) --no-build --no-restore -o $(PUBLISH_APP_DIR ) /p:Version=$(VERSION )
105
- @echo " Publish complete. Application in $( PUBLISH_APP_DIR) "
106
-
107
113
# Push NuGet packages to the source
108
114
# Depends on Pack
109
115
Push : Pack
110
116
@echo " --- Pushing NuGet Packages ---"
111
- # Check if NUGET_API_KEY is set (Makefile equivalent of .WithCriteria )
112
- $(if $( NUGET_API_KEY ) , \
113
- find $( PUBLISH_DIR ) -name " *.nupkg " -exec $( DOTNET ) nuget push {} --api-key $( NUGET_API_KEY ) --source $( NUGET_SOURCE ) \; , \
114
- @echo " NUGET_API_KEY not set. Skipping push. Set it via environment or 'make Push NUGET_API_KEY=your_key' " \
115
- )
117
+ ifeq ( $( OS ) ,Windows_NT )
118
+ $(DOTNET) nuget push "$(PUBLISH_DIR)\*.nupkg" --source $(NUGET_SOURCE) --api-key $(NUGET_API_KEY);
119
+ else
120
+ $(DOTNET) nuget push $(PUBLISH_DIR)/*.nupkg --source $(NUGET_SOURCE) --api-key $( NUGET_API_KEY);
121
+ endif
116
122
@echo "Push attempt finished."
117
-
123
+
118
124
119
125
# -----------------------------------------------------------------------------
120
126
# Help Target
@@ -129,7 +135,6 @@ help:
129
135
@echo " Build Build the solution"
130
136
@echo " Test Run unit tests"
131
137
@echo " Pack Create NuGet packages"
132
- @echo " Publish Publish the application"
133
138
@echo " Push Push NuGet packages to the source (requires NUGET_API_KEY)"
134
139
@echo " "
135
140
@echo " Variables:"
0 commit comments