Skip to content

Commit e44a915

Browse files
committed
(GH-80) existing icons will be honored
Additionally no local copy of the icon is needed anymore. The setting $(CakeContribGuidelinesIconDestinationLocation) has been removed. Any old build/project using this setting will now fail.
1 parent 0d4670f commit e44a915

20 files changed

+1002
-137
lines changed

docs/input/guidelines/CakeContribIcon.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,22 @@ Title: CakeContrib-Icon
3434
Using this package automatically enables this guideline.
3535

3636
With no special settings at all (i.e. "The Standard"):
37-
* the current cake-contrib icon will be copied as "icon.png" in the project-directory
38-
* the icon will be included in the project
37+
* if no `PackageIcon` property is specified, a default will be assigned.
38+
* if no icon (matching the `PackageIcon` property) is referenced in the project, a default will be referenced.
39+
* if the referenced icon is not binary equal to the default icon, it will be updated.
40+
* if no `PackageIconUrl` property is specified, a default will be assigned.
3941

4042
## Settings
4143

42-
### Icon-Location
43-
<?! Include "../settings/fragments/IconDestinationLocation.md" /?>
44-
4544
### Icon include in project
4645
<?! Include "../settings/fragments/IconOmitImport.md" /?>
4746

4847
## Migrating from an existing project
4948

49+
No steps are needed anymore. Existing settings will be detected and honored.
50+
51+
Optionally:
5052
* remove the existing icon
5153
* remove the `Include` of the icon from the project-file
52-
* add a reference to CakeContrib.Guidelines
53-
* build the project
54-
* set `PackageIcon` to `icon.png`
54+
* remove the `PackageIcon` from the project-file
55+
* remove the `PackageIconUrl` from the project-file

docs/input/rules/ccg0001.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,9 @@ To that end, setting `PackageIcon` is required.
2828

2929
## How to fix violations
3030

31-
Add
31+
This error will only show, if `CakeContribGuidelinesIconOmitImport` is `True` and no manual include of the icon was done.
3232

33-
```xml
34-
<PropertyGroup>
35-
<PackageIcon>$(CakeContribGuidelinesIconDestinationLocation)</PackageIcon>
36-
</PropertyGroup>
37-
```
38-
39-
to the project.
33+
To fix this error, you need to remove the definition of `CakeContribGuidelinesIconOmitImport` or define a `PackageIcon` manually.
4034

4135
## Related guidelines
4236

docs/input/rules/ccg0003.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
Order: 3
33
Title: CCG0003
4-
Description: PackageIcon points to wrong place
4+
Description: PackageIcon can not be updated
55
---
66

7-
> PackageIcon points to wrong place
7+
> The PackageIcon source (path/to/icon.jpeg) has an extension of jpeg. It can not be set from the CakeContrib-Icon.
88
99
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
1010
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
@@ -19,16 +19,27 @@ Description: PackageIcon points to wrong place
1919

2020
## Cause
2121

22-
This warning is raised, when `PackageIcon` does not point to the copied icon.
23-
(I.e. `PackageIcon` is not equal to `$(CakeContribGuidelinesIconDestinationLocation)`)
22+
This warning/error is raised, when the source of `PackageIcon` was outdated
23+
but could not be updated.
2424

2525
## Description
2626

27-
Since the correct icon is copied to `$(CakeContribGuidelinesIconDestinationLocation)` it is expected, that this icon is packaged into the nupkg.
27+
The default package icon is a `png` and will be used to update outdated icons.
28+
If a different icon format than `png` is used, simply updating that icon with a
29+
`png` content will break the icon.
30+
31+
If a `PackageIcon` is set, but no corresponding icon reference could be
32+
found, a reference should be added automatically. However, if `PackageIcon`
33+
is not set to a `png` file, such reference would not be possible.
34+
In this case `CCG0003` is an error and will break the build.
35+
36+
If a `PackageIcon` is set with a corresponding icon reference but not to
37+
a `png` file, a test whether the icon is up-to-date is not possible.
38+
In this case `CCG0003` is a warning .
2839

2940
## How to fix violations
3041

31-
Modify `PackageIcon` to point to the same place as `$(CakeContribGuidelinesIconDestinationLocation)`.
42+
Modify `PackageIcon` to point to a `png` file or remove the custom file entirely.
3243

3344
## Related guidelines
3445

docs/input/settings/fragments/IconDestinationLocation.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

docs/input/settings/fragments/IconOmitImport.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55

66
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
77

8-
The cake-contrib icon will be automatically included in the project, unless `CakeContribGuidelinesIconOmitImport` was defined.
8+
The cake-contrib icon will be automatically included in the project, unless
9+
`CakeContribGuidelinesIconOmitImport` is set to `True`.
910

1011
To to use a "custom" import the following could be used:
1112

1213
```xml
1314
<PropertyGroup>
14-
<CakeContribGuidelinesIconOmitImport>1</CakeContribGuidelinesIconOmitImport>
15+
<CakeContribGuidelinesIconOmitImport>True</CakeContribGuidelinesIconOmitImport>
16+
<PackageIcon>logo.png</PackageIcon>
1517
</PropertyGroup>
1618
<ItemGroup>
17-
<None Include="$(CakeContribGuidelinesIconDestinationLocation)">
18-
<Pack>True</Pack>
19-
<PackagePath></PackagePath>
20-
</None>
19+
<None Include="icons/logo.png" Pack="True" PackagePath="" />
2120
</ItemGroup>
2221
```

docs/input/settings/index.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ NoSidebar: true
1111
- [General](#general)
1212
- [ProjectType](#projecttype)
1313
- [Icons](#icons)
14-
- [IconDestinationLocation](#icondestinationlocation)
1514
- [IconOmitImport](#iconomitimport)
1615
- [Opt-Out](#opt-out)
1716
- [OmitRecommendedConfigFile](#omitrecommendedconfigfile)
@@ -41,9 +40,6 @@ different values than `addin` or `module` might yield unexpected results.
4140

4241
## Icons
4342

44-
### IconDestinationLocation
45-
<?! Include "./fragments/IconDestinationLocation.md" /?>
46-
4743
### IconOmitImport
4844
<?! Include "./fragments/IconOmitImport.md" /?>
4945

src/Guidelines/build/CakeContrib.Guidelines.props

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@
1717
<UsingTask
1818
TaskName="$(CakeContribGuidelinesCustomTasksNamespace).CcgLogWarning"
1919
AssemblyFile="$(CakeContribGuidelinesCustomTasksAssembly)" />
20-
21-
<Import Project="$(MSBuildThisFileDirectory)Icon.props" />
2220
</Project>

src/Guidelines/build/Icon.props

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Guidelines/build/Icon.targets

Lines changed: 51 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,54 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<!--
4-
Always copy/replace the icon.png
5-
There is no opt-out of this feature, as the opt-out is removing the reference to CakeContrib.Guidelines
6-
-->
7-
<Target Name="_CopyCakeContribGuidelinesIcon" AfterTargets="BeforeBuild" BeforeTargets="CoreBuild">
8-
<Copy
9-
SourceFiles="$(MSBuildThisFileDirectory)/../images/icon.png"
10-
DestinationFiles="$(MSBuildProjectDirectory)/$(CakeContribGuidelinesIconDestinationLocation)" />
11-
<Message
12-
Importance="normal"
13-
Text="Copied cake-contrib icon to $(MSBuildProjectDirectory)/$(CakeContribGuidelinesIconDestinationLocation)" />
14-
<Message
15-
Condition="$(CakeContribGuidelinesIconOmitImport) != ''"
16-
Importance="normal"
17-
Text="CakeContribGuidelinesIconOmitImport is set, so icon-include will be omitted" />
18-
19-
<!-- check PackageIcon -->
20-
<Message
21-
Importance="low"
22-
Text="PackageIcon is set to $(PackageIcon)" />
23-
<CcgLogError
24-
Condition="$(PackageIcon) == ''"
25-
CcgId="1"
26-
File="$(MSBuildProjectFullPath)"
27-
Text="PackageIcon is empty. Since you're using CakeContrib.Guidelines the PackageIcon should be set." />
28-
<CcgLogWarning
29-
Condition="$(PackageIcon) != '$(CakeContribGuidelinesIconDestinationLocation)'"
30-
CcgId="3"
31-
File="$(MSBuildProjectFullPath)"
32-
Text="PackageIcon should point to $(CakeContribGuidelinesIconDestinationLocation)." />
33-
34-
<!-- check PackageIconUrl -->
35-
<Message
36-
Importance="low"
37-
Text="PackageIconUrl is set to $(PackageIconUrl)" />
38-
<CcgLogWarning
39-
Condition="$(PackageIconUrl) == ''"
40-
CcgId="2"
41-
File="$(MSBuildProjectFullPath)"
42-
Text="PackageIconUrl is empty. For compatibility it should be set." />
3+
4+
<UsingTask
5+
TaskName="$(CakeContribGuidelinesCustomTasksNamespace).EnsureCakeContribIcon"
6+
AssemblyFile="$(CakeContribGuidelinesCustomTasksAssembly)" />
7+
<UsingTask
8+
TaskName="$(CakeContribGuidelinesCustomTasksNamespace).EnsureCakeContribIconUrl"
9+
AssemblyFile="$(CakeContribGuidelinesCustomTasksAssembly)" />
10+
11+
<Target Name="_CopyCakeContribGuidelinesIcon"
12+
AfterTargets="BeforeBuild"
13+
BeforeTargets="CoreBuild;SetNuspecProperties;GenerateNuspec;_GetPackageFiles">
14+
<EnsureCakeContribIcon
15+
ProjectFile="$(MSBuildProjectFullPath)"
16+
PackageIcon="$(PackageIcon)"
17+
NoneReferences="@(None)"
18+
CakeContribIconPath="$(MSBuildThisFileDirectory)/../images/icon.png"
19+
OmitIconImport="$(CakeContribGuidelinesIconOmitImport)">
20+
<Output PropertyName="TempPackageIcon" TaskParameter="PackageIconOutput" />
21+
<Output ItemName="TempNone" TaskParameter="AdditionalNoneRefOutput" />
22+
</EnsureCakeContribIcon>
23+
24+
<CreateProperty
25+
Condition="$(TempPackageIcon) != ''"
26+
Value="$(TempPackageIcon)">
27+
<Output
28+
TaskParameter="Value"
29+
PropertyName="PackageIcon" />
30+
</CreateProperty>
31+
<CreateItem
32+
Condition="@(TempNone) != ''"
33+
Include="@(TempNone)">
34+
<Output
35+
TaskParameter="Include"
36+
ItemName="None" />
37+
</CreateItem>
38+
39+
<EnsureCakeContribIconUrl
40+
ProjectFile="$(MSBuildProjectFullPath)"
41+
PackageIconUrl="$(PackageIconUrl)"
42+
OmitIconImport="$(CakeContribGuidelinesIconOmitImport)"
43+
CakeContribIconUrl="https://cdn.jsdelivr.net/gh/cake-contrib/graphics/png/cake-contrib-medium.png">
44+
<Output ItemName="TempPackageIconUrl" TaskParameter="PackageIconUrlOutput" />
45+
</EnsureCakeContribIconUrl>
46+
<CreateProperty
47+
Condition="$(TempPackageIconUrl) != ''"
48+
Value="$(TempPackageIconUrl)">
49+
<Output
50+
TaskParameter="Value"
51+
PropertyName="PackageIconUrl" />
52+
</CreateProperty>
4353
</Target>
44-
</Project>
54+
</Project>

src/Guidelines/content/readme.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
Thanks for installing CakeContrib.Guidelines.
22

3-
Currently your Visual Studio might show the icon.png as missing (with a red "x").
4-
This is due to the fact, that is not actually there. It will, however be copied upon build.
3+
MIGRATING FROM A PREVIOUS VERSION?
4+
We've eliminated the need to have a project-local copy of
5+
the Cake-Contrib icon.
56

6-
WHAT YOU HAVE TO DO:
7-
8-
Once you have built the project the "icon.png" will exist. After that open
9-
project-properties -> Package -> IconFile and input "icon.png"
7+
You can - if you like - remove the <PackageIcon> and <PackageIconUrl>
8+
tags from the csproj, as well as the local copy of the icon.
109

1110
Is there more?
12-
Yes. Read the docs at https://github.com/cake-contrib/CakeContrib.Guidelines/
11+
Yes. Read the docs at https://github.com/cake-contrib/CakeContrib.Guidelines/

0 commit comments

Comments
 (0)