Skip to content

Commit

Permalink
Merge pull request #13 from kzu/dev
Browse files Browse the repository at this point in the history
Dev > Main
  • Loading branch information
kzu authored Oct 8, 2020
2 parents 8832e91 + c19f327 commit 9390a6e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/NuGetizer.Tasks/NuGetizer.PackageMetadata.targets
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Copyright (c) .NET Foundation. All rights reserved.

<PropertyGroup Label="Hidden">
<!-- Matches the SDK Pack default when set to true. -->
<PackageId Condition="'$(IsPackable)' == 'true' and '$(PackageId)' == ''">$(AssemblyName)</PackageId>
<PackageId Condition="'$(IsPackable)' == 'true' and '$(PackageId)' == ''">$(AssemblyName)</PackageId>
<PackageId Condition="'$(IsPackable)' == 'true' and '$(PackageId)' == ''">$(MSBuildProjectName)</PackageId>
</PropertyGroup>

<ItemDefinitionGroup>
Expand Down
1 change: 1 addition & 0 deletions src/NuGetizer.Tasks/NuGetizer.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<PropertyGroup Label="Hidden">
<!-- Matches the SDK Pack default when set to true. -->
<PackageId Condition="'$(IsPackable)' == 'true' and '$(PackageId)' == ''">$(AssemblyName)</PackageId>
<PackageId Condition="'$(IsPackable)' == 'true' and '$(PackageId)' == ''">$(MSBuildProjectName)</PackageId>

<IsPackable Condition="'$(IsPackable)' == '' and '$(PackageId)' != ''">true</IsPackable>
<IsPackable Condition="'$(IsPackable)' == '' and '$(PackageId)' == ''">false</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetizer.Tasks/NuGetizer.Tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.9.20" PrivateAssets="all" />
<PackageReference Include="NuGet.Packaging" Version="5.7.0" PrivateAssets="all" />
<PackageReference Include="NuGet.ProjectManagement" Version="4.2.0" PrivateAssets="all" />
<PackageReference Include="ThisAssembly" Version="1.0.0-alpha" />
<PackageReference Include="ThisAssembly" Version="1.0.0-alpha" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion src/NuGetizer.Tests/Builder.NuGetizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ public static TargetResult BuildProject(
params (string name, string contents)[] files)
{
using var sha = new SHA1Managed();

// Combination of last write time for the test assembly + contents of the projects.
var hash = Base62.Encode(Math.Abs(BitConverter.ToInt64(
sha.ComputeHash(Encoding.UTF8.GetBytes(projectContent)), 0)));
sha.ComputeHash(Encoding.UTF8.GetBytes(projectContent + string.Join("|", files.Select(f => f.contents)))), 0)));

var scenarioName = hash;
var scenarioDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Scenarios", scenarioName);
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetizer.Tests/Scenarios/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<Import Project="$(NuGetRestoreTargets)" Condition="'$(IsRestoreTargetsFileLoaded)' != 'true' and '$(NuGetRestoreTargets)' != ''" />
<Import Project="$(NuGetTargets)" Condition="'$(ResolveNuGetPackageAssetsDependsOn)' == '' and '$(NuGetTargets)' != ''" />

<Import Project="Scenario.targets" Condition="'$(IsNuGetized)' == 'true'" />
<Import Project="Scenario.targets" Condition="'$(ScenarioTargetsImported)' != 'true' and '$(IsNuGetized)' != 'false'" />

</Project>
4 changes: 4 additions & 0 deletions src/NuGetizer.Tests/Scenarios/Scenario.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<Import Project="$(NuGetTargetsPath)\NuGetizer.targets" Condition="'$(IsCrossTargetingBuild)' != 'true' and '$(NuGetizerTargetsImported)' != 'true' and Exists('$(NuGetTargetsPath)\NuGetizer.targets')" />
<Import Project="$(NuGetTargetsPath)\NuGetizer.Multitargeting.targets" Condition="'$(IsCrossTargetingBuild)' == 'true' and '$(NuGetizerTargetsImported)' != 'true' and Exists('$(NuGetTargetsPath)\NuGetizer.Multitargeting.targets')" />

<PropertyGroup>
<ScenarioTargetsImported>true</ScenarioTargetsImported>
</PropertyGroup>

<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)_._" />
</ItemGroup>
Expand Down
6 changes: 1 addition & 5 deletions src/NuGetizer.Tests/given_an_empty_library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,14 @@ public void when_is_packable_true_but_packageid_reset_to_empty_then_fails()
<IsPackable>true</IsPackable>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>", output: output,
files: (name: "Directory.Build.targets", @"
<Project>
<Import Project='$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets, $(MSBuildThisFileDirectory)..))' />
<Target Name='BeforeEverything' BeforeTargets='PrepareForBuild'>
<!-- We need to try harder to reset it to empty, since it's defaulted
in this case to the AssemblyName automatically -->
<PropertyGroup>
<PackageId />
</PropertyGroup>
</Target>
</Project>"));
</Project>", output: output);

Assert.Equal(TargetResultCode.Failure, result.ResultCode);
// Next best to checking the full string. No way I could find to
Expand Down

0 comments on commit 9390a6e

Please sign in to comment.