I want to include the WinJS source in my project. It comes with minified versions of its *.js
and *.css
files. To save space I want to include only the minified versions with Release configurations
.
That's what I have come up with so far:
<Content Include="WinJS\css\*.css;WinJS\js\*.js" Condition="$(Configuration) == 'Debug'">
<Link>WinJS\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Content>
<Content Include="WinJS\css\*.min.css;WinJS\js\*.min.js" Condition="$(Configuration) == 'Release'">
<Link>WinJS\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Content>
There are 2 problems with that:
Debug Configuration
also contains the .min.*
files. That would be a minor problem.RecursiveDir
that wayRelease Configuration
the .min
part should be dropped, so that I can reference the files always with one name in my code (<script src="/WinJS/js/WinJS.js"/>
)The expected result in the project should always be:
WinJS/css/ui-light.css
WinJS/css/ui-dark.css
WinJS/js/WinJS.js
either coming from the .min
versions in Release Configuration
or the non-minified versions in Debug Configuration
.
Maybe something clever could be done combining Include
and Exclude
?
%(RecursiveDir) items metadata are available just in case you use wildchar **. See documenation of MSBuild Well-known Item Metadata
I’m don't use WinJS but in case Link metadata are used in places where you need reference the files js and css files this could be solution for you:
<Content Include="WinJS\**\*.css;WinJS\**\*.js" Exclude="WinJS\**\*.min.css;WinJS\**\*.min.js" Condition="$(Configuration) == 'Debug'" >
<Link>WinJS\%(RecursiveDir)%(FileName)%(Extension)</Link>
</Content>
<Content Include="WinJS\**\*.min.css;WinJS\**\*.min.js" Condition="$(Configuration) == 'Release'">
<Link>WinJS\%(RecursiveDir)$([System.String]::Copy("(Filename)").Replace(".min",""))%(Extension)</Link>
</Content>