Skip to content

Commit

Permalink
Allow packing from the IDE, and cleanup package contents
Browse files Browse the repository at this point in the history
When running Pack from the IDE, the output tasks assembly will be locked, so it requires killing MSBuild.exe afterwards, but it can be a convenient way to peek at the output.

Alternatively, you can set MSBUILDDISABLENODEREUSE=1 via envvar (i.e. before launching VS) and that would allow a more iterative approach.
  • Loading branch information
kzu committed Sep 24, 2020
1 parent 8c48e87 commit 850a0d7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
- run: echo "::add-path::$(vs where preview --prop=InstallationPath)\MSBuild\Current\Bin"
- run: msbuild -r
- run: msbuild -t:test
- run: msbuild -t:pack -p:version=42.42.42-$(git name-rev --name-only --refs=refs/heads/* HEAD).$(git rev-list --count a12adfe..HEAD)
- run: msbuild -t:pack -p:packonbuild=true -p:version=42.42.42-$(git name-rev --name-only --refs=refs/heads/* HEAD).$(git rev-list --count a12adfe..HEAD)
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ steps:
- publish: $(System.DefaultWorkingDirectory)/logs
artifact: logs
condition: always()
- script: msbuild -t:pack
- script: msbuild -t:Pack -p:PackOnBuild=true
displayName: msbuild -t:pack
8 changes: 7 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
<CI Condition="'$(TF_BUILD)' == 'true'">true</CI>
</PropertyGroup>

<Target Name="Pack" />
<Target Name="Pack" Condition="$(IsPackable)" Returns="@(PackOutput)">
<!-- Typically called in the IDE when we run Pack context menu. -->
<MSBuild Projects="$(MSBuildProjectFullPath)" Properties="PackOnBuild=true" Targets="Pack">
<Output TaskParameter="TargetOutputs" ItemName="PackOutput"/>
</MSBuild>
</Target>

<Target Name="Test" />

<Import Project="NuGetizer.Tasks\NuGetizer.props" Condition="'$(PackOnBuild)' == 'true'" />
Expand Down
1 change: 1 addition & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup Label="Pack">
<IsPackable Condition="'$(IsPackable)' == '' and '$(PackageId)' != ''">true</IsPackable>
<IsPackable Condition="'$(IsPackable)' == '' and '$(PackageId)' == ''">false</IsPackable>
<ImportNuGetBuildTasksPackTargetsFromSdk Condition="'$(PackOnBuild)' != 'true'">false</ImportNuGetBuildTasksPackTargetsFromSdk>
</PropertyGroup>

<Import Project="NuGetizer.Tasks\$(OutputPath)NuGetizer.targets" Condition="$(IsPackable) and '$(PackOnBuild)' == 'true'" />
Expand Down
11 changes: 8 additions & 3 deletions src/NuGetizer.Tasks/NuGetizer.Tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
</ItemGroup>

<ItemGroup>
<Content Include="@(None)" Exclude="NuGetizer.Tasks.targets" CopyToOutputDirectory="PreserveNewest" />
<ProjectCapability Include="Pack" />
</ItemGroup>

<ItemGroup>
<None Update="@(None)" CopyToOutputDirectory="PreserveNewest" Pack="true" />
<Content Update="NuGetizer.MultiTargeting.targets" PackagePath="buildMultiTargeting\NuGetizer.targets" />
<None Include="NuGetizer.props;NuGetizer.Common.targets;NuGetizer.PackageMetadata.targets"
PackagePath="buildMultiTargeting\%(Filename)%(Extension)" />
<Content Include="..\..\img\nugetizer-256.png" Link="icon-236.png" CopyToOutputDirectory="PreserveNewest" PackagePath="icon.png" />
PackagePath="buildMultiTargeting\%(Filename)%(Extension)"
Pack="true" />
<None Include="..\..\img\nugetizer-256.png" Link="icon.png" CopyToOutputDirectory="PreserveNewest" PackagePath="icon.png" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 850a0d7

Please sign in to comment.