Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit d465a7b

Browse files
kzuadalon
authored andcommitted
Fail the build if the right nugetizer nuget package cannot be deployed/packaged
This makes far easier to detect cases where the nugetizer package doesn't exist, and later on template unfolding will fail. It won't happen for CI builds, since the right builds happen in the right order, but it's quite easy to make this mistake for developer builds while iterating on the extension.
1 parent 1171cf8 commit d465a7b

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/VisualStudio/NuGet.Packaging.VisualStudio.Shared.targets

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<XmlNs>&lt;Namespace Prefix='vs' Uri='http://schemas.microsoft.com/developer/vstemplate/2005'/&gt;</XmlNs>
1919
</PropertyGroup>
2020

21+
<!-- Embeds the NuGetizer package into the VSIX -->
2122
<ItemGroup>
2223
<!-- NOTE: this will only work if the solution was built at least once from the command line,
2324
since the project reference below would have built the package in that case. -->
@@ -39,6 +40,28 @@
3940
</ProjectReference>
4041
</ItemGroup>
4142

43+
<Target Name="EnsureNuGetizerPackage" DependsOnTargets="GetVersion" BeforeTargets="DeployVsixExtensionFiles;CreateVsixContainer">
44+
<ItemGroup>
45+
<_NuGetizerPackage Include="$(Out)\*.nupkg" />
46+
<_CurrentNuGetizerPackage Include="@(_NuGetizerPackage)"
47+
Condition="$([System.String]::New('%(Filename)').Replace('NuGet.Build.Packaging.', '')) == '$(Version)'" />
48+
</ItemGroup>
49+
50+
<PropertyGroup>
51+
<_NuGetizerPackageExists Condition="'@(_NuGetizerPackage -> Count())' != '0'">true</_NuGetizerPackageExists>
52+
<_CurrentNuGetizerPackageExists Condition="'@(_CurrentNuGetizerPackage -> Count())' != '0'">true</_CurrentNuGetizerPackageExists>
53+
</PropertyGroup>
54+
55+
<Delete Files="$(TargetPath)" Condition="'$(_NuGetizerPackageExists)' != 'true' Or '$(_CurrentNuGetizerPackageExists)' != 'true'" />
56+
57+
<Error Condition="'$(_NuGetizerPackageExists)' != 'true'" Text="NuGetizer nuget package was not found under '$(Out)'.
58+
Run 'build.cmd' at least once, or run 'msbuild' from the 'src\Build' folder to build the nuget package." />
59+
60+
<Error Condition="'$(_CurrentNuGetizerPackageExists)' != 'true'" Text="Required NuGetizer nuget package version '$(Version)' was not found under '$(Out)'.
61+
Run 'build.cmd' at least once, or run 'msbuild' from the 'src\Build' folder to build the nuget package.
62+
Packages found were: %0a@(_NuGetizerPackage -> ' %(Filename)%(Extension)', '%0a')" />
63+
</Target>
64+
4265
<Target Name="GetVersion" DependsOnTargets="GitVersion" Returns="$(Version)">
4366
<PropertyGroup>
4467
<Version>$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)</Version>

src/VisualStudio/NuGet.Packaging.VisualStudio/NuGet.Packaging.VisualStudio.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@
8484
</Compile>
8585
<Compile Include="Views\ViewModelBase.cs" />
8686
<Compile Include="Wizards\MultiPlatformWizard.cs" />
87+
<None Include="..\NuGet.Packaging.VisualStudio.Shared.targets">
88+
<Link>NuGet.Packaging.VisualStudio.Shared.targets</Link>
89+
</None>
8790
<None Include="NuGet.Packaging.VisualStudio.targets">
8891
<SubType>Designer</SubType>
8992
</None>

0 commit comments

Comments
 (0)