Reputation: 11
One of my 3rd party libraries has a license file that it always adds to the csproj file each time we load the designer in VS. If I simply ignore the file, I still need to delete in VS from the Solution Explorer and I tend to forget before pushing to our source control as it is not needed. If there a way to remove the entry in the BeforeBuild target or similar if it is found?
Below is what I'm looking to remove on each build during a build:
<ItemGroup>
...
<EmbeddedResource Include="Properties\licenses.licx" />
...
</ItemGroup>
this is a good start, but I could not figure out how to modify for my needs: Remove MSBuild DLL reference regardless of version (by wildcard) in VS 2015
Upvotes: 1
Views: 992
Reputation: 5452
You could create a property setted on the configuration and test the condition to include the file
Like this :
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<WithLicense>1</WithLicense>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<WithLicense>0</WithLicense>
</PropertyGroup>
<ItemGroup>
...
<EmbeddedResource Include="Properties\licenses.licx" Condition="$(WithLicense)==1"/>
...
</ItemGroup>
Upvotes: 1