命名空间属性已设置但为空

时间:2014-06-21 16:46:37

标签: .net msbuild wix msdn wix3.8

我编写了一个不会编译的内联msbuild任务。该错误显示"命名空间'属性已设置但为空。如果'命名空间'属性设置它不能为空。" 注意:这是Wix安装程序项目。这是我的代码:

<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
         <ConnectionString Condition=" '$(ConnectionString)' == ''">Server=???;Database=???;Integrated Security=True;</ConnectionString>
         <SqlCommand Condition=" '$(SqlCommand)' == '' ">???</SqlCommand>
    </PropertyGroup>

    <UsingTask 
        TaskName="ExecuteScalar" 
        TaskFactory="CodeTaskFactory"
        AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
            <ParameterGroup>
                <ConnectionString ParameterType="System.String" Required="true" />
                <CommandText ParameterType="System.String" Required="true" />
                <Result ParameterType="System.String" Output="true" />
            </ParameterGroup>
        <Task>
            <Reference Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll" />      
            <Using Namespace="System.Data.SqlClient" />
            <Using Namepsace="System.Data.Sql" />
            <Code Type="Fragment" Language="cs"><![CDATA[
                using (SqlConnection conn = new SqlConnection(ConnectionString))
                {

                  conn.Open();

                  using (SqlCommand cmd = new SqlCommand(CommandText, conn))
                  {
                    cmd.CommandType = System.Data.CommandType.Text;             

                    Result = cmd.ExecuteScalar() as string;
                  }}]]>
             </Code>
        </Task>
    </UsingTask>

    <Target Name="MyTarget">   
        <ExecuteScalar ConnectionString="$(ConnectionString)"
                   CommandText="$(SqlCommand)">
            <Output TaskParameter="Result" PropertyName="MyProperty" />
        </ExecuteScalar>
    </Target>

    <PropertyGroup>
        <BuildDependsOn>
            BeforeBuild;
            CoreBuild;
            AfterBuild
        </BuildDependsOn>
    </PropertyGroup>

    <Target Name="Build" DependsOnTargets="$(BuildDependsOn)" />

    <PropertyGroup>
         <BuildDependsOn>
            MyTarget;
            $(BuildDependsOn)
         </BuildDependsOn>
    </PropertyGroup>

当我搜索此错误时,我找不到任何内容。我感谢任何帮助。

我一直在引用:

1 个答案:

答案 0 :(得分:4)

你这里有一个错字:

<Using Namepsace="System.Data.Sql" />

Namepsace更改为Namespace