views:

313

answers:

2

How can I add a silverlight-3.0 target framework to NAnt? I tried modifying the nant.exe.config file, based on silverlight-2.0 profile, but that fails during compilation with CS0518: Type "System.Object" not defined or imported [error message translated from Polish]. Also, the silverlight-2.0 target does not seem to set "SILVERIGHT" conditional compilation define like Visual Studio does, which complicates writing multi-target libraries.

Does anyone here build mixed target solutions (with libraries for both full .NET framework and Silverlight)?

A: 

@skolima... could this be that you're not pointing to the right directories? I'm actually wondering this one myself, as I'm working with SL3 and would like to do build automation using nAnt.

Also wondering, based on some other posts here on SO that you may need to edit the nant.exe.config file to add the "profile" for silverlight-3 there as well.

Richard B
+3  A: 

It looks like Richard B was on the right track with the Nant.exe.config modifications. I added the following chunk of XML to the config file, and was able to set the nant.settings.currentframework property to silverlight-3.0 in my main build file, and things worked like a charm. (Note: I put this in the config file on line 775 just after the silverlight-2.0 framework definition). Hope this helps

        <framework 
                name="silverlight-3.0" 
                family="silverlight" 
                version="3.0"
                description="Microsoft Silverlight 3.0" 
                sdkdirectory="${path::combine(sdkInstallRoot, 'bin')}" 
                frameworkdirectory="${path::combine(installRoot, 'v3.5')}" 
                frameworkassemblydirectory="${environment::get-folder-path('ProgramFiles')}/Microsoft Silverlight/3.0.40818.0"
                clrversion="2.0.50727"
                >
                <runtime>
                    <modes>
                        <strict>
                            <environment>
                                <variable name="COMPLUS_VERSION" value="v2.0.50727" />
                            </environment>
                        </strict>
                    </modes>
                </runtime>
                <reference-assemblies basedir="${environment::get-folder-path('ProgramFiles')}/Microsoft Silverlight/3.0.40818.0">
                    <include name="agclr.dll" />
                    <include name="Microsoft.VisualBasic.dll" />
                    <include name="mscorlib.dll" />
                    <include name="System.Core.dll" />
                    <include name="System.dll" />
                    <include name="System.Silverlight.dll" />
                    <include name="System.Xml.dll" />
  <include name="System.Windows.dll" />
  <include name="System.Windows.Browser.dll" />
                </reference-assemblies>
                <task-assemblies>
                    <!-- include MS.NET version-neutral assemblies -->
                    <include name="extensions/net/neutral/**/*.dll" />
                    <!-- include MS.NET 2.0 specific assemblies -->
                    <include name="extensions/net/2.0/**/*.dll" />
                    <!-- include MS.NET specific task assembly -->
                    <include name="NAnt.MSNetTasks.dll" />
                    <!-- include MS.NET specific test assembly -->
                    <include name="NAnt.MSNet.Tests.dll" />
                    <!-- include .NET 2.0 specific assemblies -->
                    <include name="extensions/common/2.0/**/*.dll" />
                </task-assemblies>
                <tool-paths>
                    <directory name="${path::combine(sdkInstallRoot, 'bin')}"
                        if="${property::exists('sdkInstallRoot')}" />
                    <directory name="${path::combine(installRoot, 'v2.0.50727')}" />
                    <directory name="${environment::get-folder-path('ProgramFiles')}/Microsoft Silverlight/3.0.40818.0" />
                </tool-paths>
                <project>
                    <readregistry
                        property="installRoot"
                        key="SOFTWARE\Microsoft\.NETFramework\InstallRoot"
                        hive="LocalMachine" />
                    <readregistry
                        property="sdkInstallRoot"
                        key="SOFTWARE\Microsoft\.NETFramework\sdkInstallRootv2.0"
                        hive="LocalMachine"
                        failonerror="false" />
                </project>
                <tasks>
                    <task name="csc">
                        <attribute name="noconfig">true</attribute>
                        <attribute name="nostdlib">true</attribute>
                        <attribute name="supportsnowarnlist">true</attribute>
                        <attribute name="supportswarnaserrorlist">true</attribute>
                        <attribute name="supportskeycontainer">true</attribute>
                        <attribute name="supportskeyfile">true</attribute>
                        <attribute name="supportsdelaysign">true</attribute>
                        <attribute name="supportsplatform">true</attribute>
                        <attribute name="supportslangversion">true</attribute>
                    </task>
                    <task name="vbc">
                        <attribute name="nostdlib">true</attribute>
                        <attribute name="supportsdocgeneration">true</attribute>
                        <attribute name="supportsnostdlib">true</attribute>
                        <attribute name="supportsnowarnlist">true</attribute>
                        <attribute name="supportskeycontainer">true</attribute>
                        <attribute name="supportskeyfile">true</attribute>
                        <attribute name="supportsdelaysign">true</attribute>
                        <attribute name="supportsplatform">true</attribute>
                        <attribute name="supportswarnaserrorlist">true</attribute>
                    </task>
                    <task name="jsc">
                        <attribute name="supportsplatform">true</attribute>
                    </task>
                    <task name="vjc">
                        <attribute name="supportsnowarnlist">true</attribute>
                        <attribute name="supportskeycontainer">true</attribute>
                        <attribute name="supportskeyfile">true</attribute>
                        <attribute name="supportsdelaysign">true</attribute>
                    </task>
                    <task name="resgen">
                        <attribute name="supportsassemblyreferences">true</attribute>
                        <attribute name="supportsexternalfilereferences">true</attribute>
                    </task>
                    <task name="delay-sign">
                        <attribute name="exename">sn</attribute>
                    </task>
                    <task name="license">
                        <attribute name="exename">lc</attribute>
                        <attribute name="supportsassemblyreferences">true</attribute>
                    </task>
                </tasks>
            </framework>
ckramer
Thx @ckramer... I'll have to try your script at some point... Can you post your nAnt build file so that we can see your usage (esp. for creating the xap file?)
Richard B