Skip to content

Commit

Permalink
Include sample project in ReplaceVersion target, fix PushToNuget target
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Feb 28, 2018
1 parent 37c972c commit b73a6b6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions FileParserSolution/FileParser/FileParser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -67,35 +67,35 @@
<Target Name="ReplaceVersion" Condition="$(VersionTag) != ''" DependsOnTargets="Build">
<Message Text="***Replacing current version $(Version) by new version $(VersionTag)***" Importance="high"></Message>
<PropertyGroup>
<ExampleRoute>$(ProjectDir)\..\..\Examples\FileParserExample\FileParserExample.csproj</ExampleRoute>
<ExistingVersionRegex>&lt;Version>.*&lt;/Version</ExistingVersionRegex>
<NewVersionRegex>&lt;Version>$(VersionTag)&lt;/Version</NewVersionRegex>
<ExistingReference>Include=&quot;$(AssemblyName)&quot; Version=&quot;.*&quot;</ExistingReference>
<NewReference>Include=&quot;$(AssemblyName)&quot; Version=&quot;$(VersionTag)&quot;</NewReference>
</PropertyGroup>
<!--<Message Text="***Replacing '$(ExistingVersion)' by '$(NewVersion)'" Importance="high"></Message>-->
<ReplaceFileText InputFilename="FileParser.csproj" OutputFilename="FileParser.csproj"
MatchExpression="$(ExistingVersionRegex)" ReplacementText="$(NewVersionRegex)" />
<!--<Message Text="***Replacing '$(ExistingReference)' by '$(NewReference)'" Importance="high"></Message>-->
<ReplaceFileText InputFilename="$(NugetTestDir)" OutputFilename="$(NugetTestDir)"
MatchExpression="$(ExistingReference)" ReplacementText="$(NewReference)" />
<ReplaceFileText InputFilename="$(NugetTestDir)" OutputFilename="$(NugetTestDir)"
MatchExpression="$(ExistingReference)" ReplacementText="$(NewReference)" />
<ReplaceFileText InputFilename="$(ExampleRoute)" OutputFilename="$(ExampleRoute)"
MatchExpression="$(ExistingReference)" ReplacementText="$(NewReference)" />
</Target>

<Target Name="TestNugetPackageLocally">
<Message Text="***Testing created Nuget package locally***" Importance="high"></Message>
<Exec Command="dotnet test $(NugetTestDir)" ContinueOnError="false"></Exec>
</Target>

<!--Currently not working. Manually, from Artifacts folder, the following command works:-->
<!--nuget push FileParser.0.1.0.nupkg -Source https://api.nuget.org/v3/index.json -Verbosity detailed-->
<!--ApiKey cannot be inferred from a SetApiKey previously made outside of the build script-->
<Target Name="PushToNuget" Condition="$(ApiKey) != '' AND $(VersionTag) != '' " DependsOnTargets="TestNugetPackageLocally">
<PropertyGroup>
<NugetPackageName>$(AssemblyName).$(VersionTag).nupkg</NugetPackageName>
</PropertyGroup>
<Message Text="***Pushing $(NugetPackageName) to Nuget***" Importance="high"></Message>
<!--<Exec Command="cd $(NugetPackagesDir)"></Exec>-->
<Exec Command="nuget push $(NugetPackagesDir)\$(NugetPackageName) -Source https://api.nuget.org/v3/index.json -Verbosity detailed"
Condition="$(ApiKey) == 'RealApiKey' AND Exists('$(NugetPackagesDir)\$(NugetPackageName)')" ContinueOnError="false"></Exec>
<Message Text="***$(NugetPackageName) has been successfully pushed to Nuget***" Importance="high"
Condition="$(ApiKey) == 'RealApiKey' AND Exists('$(NugetPackagesDir)\$(NugetPackageName)')"></Message>
<Exec Command="nuget push $(NugetPackagesDir)$(NugetPackageName) -ApiKey $(ApiKey) -Source https://api.nuget.org/v3/index.json -Verbosity detailed"
Condition="Exists('$(NugetPackagesDir)$(NugetPackageName)')" ContinueOnError="false"></Exec>
<Message Text="***$(NugetPackageName) has been successfully pushed to Nuget***" Importance="high"></Message>
</Target>
</Project>

0 comments on commit b73a6b6

Please sign in to comment.