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)?

3 Answers 3

3

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>
2
  • 1
    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
    Nov 30, 2009 at 5:31
  • <framework frameworkassemblydirectory> and <reference-assemblies basedir> can be set to "${environment::get-folder-path('ProgramFiles')}/Reference Assemblies/Microsoft/Framework/Silverlight/v3.0" if you are running a Silverlight v4 environment and have Silverlight 3 SDK installed. The SL3 assembly directory in ckramer's example doesnt exists when SL4 is installed. Nov 1, 2010 at 10:38
1

You can download the NAnt 0.91 Alpha 2 Release, which includes support for the net-4.0 framework. That framework works for compiling solutions with Silverlight 4 apps.

I have a solution that includes a Silverlight 4 application and a .NET 3.5 ASP.NET web project and I'm using the alpha release net-4.0 framework to compile and it works great.

Alternatively, still using the Nant alpha version, if you just need to compile a SilverLight 4 application with Nant and you can grab the silverlight-4.0 framework tag from Nant CVS here. and add that tag to your Nant.exe.config file.

0

@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.