visual studio - interface custom preprocessor task in WP7 project compilation by modying the csproj file -
i have visual studio solution 2 windows phone 7 projects. 1 main project, other links xaml pages first.
i try modify .csproj file of second project in order preprocess linked pages custom task. modifications based upon sample solution of this blog post :
xaml pages indeed processed custom task output files not used in continuation of compiling process. guess involved portion of code :
<itemgroup> <processedpages include="@(page->'%(link)')" /> <!-- remove original (linked) pages not compiled. --> <page remove="@(page)" condition="('%(page.link)' != '')" /> <!-- include processed pages instead. --> <page include="@(processedpages)" /> </itemgroup>
how modify markupcompilepass1 use output file of preprocessortask task ?
by way, don’t value of @(page->'%(link)') during compilation.
compelete project file reference :
<?xml version="1.0" encoding="utf-8"?> <project toolsversion="4.0" defaulttargets="build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <usingtask taskname="xamlpreprocessor.preprocessortask" assemblyfile="c:\users\louis\documents\visual studio 2010\projects\xamlpreprocessor\xamlpreprocessor\bin\debug\xamlpreprocessor.exe" /> <propertygroup> <configuration condition=" '$(configuration)' == '' ">debug</configuration> <platform condition=" '$(platform)' == '' ">anycpu</platform> <productversion>10.0.20506</productversion> <schemaversion>2.0</schemaversion> <projectguid>{c835df63-2335-4946-b343-186e556c4fec}</projectguid> <projecttypeguids>{c089c8c0-30e0-4e22-80c0-ce093f111a43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} </projecttypeguids> <outputtype>library</outputtype> <appdesignerfolder>properties</appdesignerfolder> <rootnamespace>processortest</rootnamespace> <assemblyname>processortest</assemblyname> <targetframeworkversion>v4.0</targetframeworkversion> <silverlightversion>$(targetframeworkversion)</silverlightversion> <targetframeworkprofile>windowsphone71</targetframeworkprofile> <targetframeworkidentifier>silverlight</targetframeworkidentifier> <silverlightapplication>true</silverlightapplication> <supportedcultures> </supportedcultures> <xapoutputs>true</xapoutputs> <generatesilverlightmanifest>true</generatesilverlightmanifest> <xapfilename>processortest.xap</xapfilename> <silverlightmanifesttemplate>properties\appmanifest.xml</silverlightmanifesttemplate> <silverlightappentry>processortest.app</silverlightappentry> <validatexaml>true</validatexaml> <throwerrorsinvalidation>true</throwerrorsinvalidation> </propertygroup> <propertygroup condition=" '$(configuration)|$(platform)' == 'debug|anycpu' "> <debugsymbols>true</debugsymbols> <debugtype>full</debugtype> <optimize>false</optimize> <outputpath>bin\debug</outputpath> <defineconstants>trace;debug;silverlight;windows_phone;wp8</defineconstants> <nostdlib>true</nostdlib> <noconfig>true</noconfig> <errorreport>prompt</errorreport> <warninglevel>4</warninglevel> </propertygroup> <propertygroup condition=" '$(configuration)|$(platform)' == 'release|anycpu' "> <debugtype>pdbonly</debugtype> <optimize>true</optimize> <outputpath>bin\release</outputpath> <defineconstants>trace;silverlight;windows_phone</defineconstants> <nostdlib>true</nostdlib> <noconfig>true</noconfig> <errorreport>prompt</errorreport> <warninglevel>4</warninglevel> </propertygroup> <itemgroup> <reference include="microsoft.phone" /> <reference include="microsoft.phone.interop" /> <reference include="system.windows" /> <reference include="system" /> <reference include="system.core" /> <reference include="system.net" /> <reference include="system.xml" /> <reference include="mscorlib.extensions" /> </itemgroup> <itemgroup> <compile include="..\appli2\mainpage.xaml.cs"> <link>mainpage.xaml.cs</link> <dependentupon>mainpage.xaml</dependentupon> </compile> <compile include="..\appli2\page2.xaml.cs"> <link>page2.xaml.cs</link> <dependentupon>page2.xaml</dependentupon> </compile> <compile include="app.xaml.cs"> <dependentupon>app.xaml</dependentupon> </compile> <compile include="properties\assemblyinfo.cs" /> </itemgroup> <itemgroup> <applicationdefinition include="app.xaml"> <subtype>designer</subtype> <generator>msbuild:compile</generator> </applicationdefinition> </itemgroup> <itemgroup> <none include="properties\appmanifest.xml" /> <none include="properties\wmappmanifest.xml" /> </itemgroup> <itemgroup> <content include="applicationicon.png"> <copytooutputdirectory>preservenewest</copytooutputdirectory> </content> <content include="background.png"> <copytooutputdirectory>preservenewest</copytooutputdirectory> </content> <content include="splashscreenimage.jpg" /> </itemgroup> <itemgroup> <page include="..\appli2\mainpage.xaml"> <link>mainpage.xaml</link> <generator>msbuild:compile</generator> <subtype>designer</subtype> </page> <page include="..\appli2\page2.xaml"> <link>page2.xaml</link> <generator>msbuild:compile</generator> <subtype>designer</subtype> </page> </itemgroup> <import project="$(msbuildextensionspath)\microsoft\silverlight phone\$(targetframeworkversion)\microsoft.silverlight.$(targetframeworkprofile).overrides.targets" /> <import project="$(msbuildextensionspath)\microsoft\silverlight phone\$(targetframeworkversion)\microsoft.silverlight.csharp.targets" /> <!-- modify build process, add task inside 1 of targets below , uncomment it. other similar extension points exist, see microsoft.common.targets. <target name="beforebuild"> </target> <target name="afterbuild"> </target> --> <propertygroup> <markupcompilepass1dependson> $(compilexamldependson) preprocessxaml; </markupcompilepass1dependson> </propertygroup> <target name="preprocessxaml"> <!-- run preprocessor on every page added project link. processed file saved @ link position. --> <!--<exec condition="('%(page.link)' != '')" command="xamlpreprocessor.exe "%(page.fullpath)" "%(page.link)""/>--> <preprocessortask symbols="$(defineconstants)" file="%(page.fullpath)" outname="%(page.link)" condition="('%(page.link)' != '')" /> <copy sourcefiles="%(page.link)" destinationfolder="c:\users\louis\desktop\temp\" /> <itemgroup> <processedpages include="@(page->'%(link)')" /> <!-- remove original (linked) pages not compiled. --> <page remove="@(page)" condition="('%(page.link)' != '')" /> <!-- include processed pages instead. --> <page include="@(processedpages)" /> </itemgroup> </target>
Comments
Post a Comment