Skip to content

Commit f4ca51b

Browse files
avimraAlexUstinov
authored andcommitted
Use the user name and password for publishing packages instead of an API key
1 parent 1c24adb commit f4ca51b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Publish/NuGetPublish.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<NoBuild>true</NoBuild>
@@ -20,7 +20,8 @@
2020
<!-- Force Release Configuration build and check env variables / User.Directory.Build.props -->
2121
<Target Name="_CheckConfiguration" BeforeTargets="CoreBuild">
2222
<Error Condition="'$(Configuration)' != 'Release'" Text="You should build this project only in 'Release' configuration. Use `dotnet build -c Release`" />
23-
<Error Condition="'$(DoNugetFeedApiKey)' == ''" Text="You should set 'DoNugetFeedApiKey' property in User.Directory.Build.props or in env variable" />
23+
<Error Condition="'$(DoNugetFeedUserName)' == ''" Text="You should set 'DoNugetFeedUserName' property in User.Directory.Build.props or in env variable" />
24+
<Error Condition="'$(DoNugetFeedPassword)' == ''" Text="You should set 'DoNugetFeedPassword' property in User.Directory.Build.props or in env variable" />
2425
<Error Condition="'$(DoNugetFeedUrl)' == ''" Text="You should set 'DoNugetFeedUrl' property in User.Directory.Build.props or in env variable" />
2526
</Target>
2627

@@ -51,6 +52,7 @@
5152
<!-- If package-lock.json has changed, perform an NPM install -->
5253
<Target Name="PublishToNuget" AfterTargets="Pack" DependsOnTargets="Pack">
5354
<Message Importance="high" Text="Publish nupkg %(NugetPublishInput.Identity) to server" />
54-
<Exec Command="dotnet nuget push %(NugetPublishInput.Identity) --force-english-output --timeout 60 --api-key $(DoNugetFeedApiKey) --source $(DoNugetFeedUrl)" WorkingDirectory="$(SolutionDir)_Build\Release\packages" />
55+
<Exec Command="dotnet nuget add source $(DoNugetFeedUrl) --username $(DoNugetFeedUserName) --password $(DoNugetFeedPassword) --store-password-in-clear-text" WorkingDirectory="$(SolutionDir)_Build\Release\packages" />
56+
<Exec Command="dotnet nuget push %(NugetPublishInput.Identity) --force-english-output --timeout 60 --api-key az --source $(DoNugetFeedUrl)" WorkingDirectory="$(SolutionDir)_Build\Release\packages" />
5557
</Target>
5658
</Project>

User.Directory.Build.props.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="latest">
33
<PropertyGroup Label="User defined variables">
4-
<DoNugetFeedApiKey>Put key Here</DoNugetFeedApiKey>
4+
<DoNugetFeedUserName>Put username here</DoNugetFeedUserName>
5+
<DoNugetFeedPassword>Put password here</DoNugetFeedPassword>
56
<DoNugetFeedUrl>Put url here</DoNugetFeedUrl>
67
</PropertyGroup>
78
</Project>

0 commit comments

Comments
 (0)