Microsoft Developer Network > Forenhomepage > MSBuild > Error MSB4041 in Getting Started Tutorial
Stellen Sie eine FrageStellen Sie eine Frage
 

BeantwortetError MSB4041 in Getting Started Tutorial

  • Dienstag, 23. September 2008 15:46Cyberherbalist TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Enthält Code

    Just getting started with MSBuild, I downloaded the Get Started with MSBuild tutorial and ran into a problem right out of the gate with the first tutorial project found in "Write a Simple Project".  I took the Hello World example and just ran it.  This consists of a console app, HelloWorldCS, and a project file, which looks like:

    <Project MSBuildVersion = "1.0" DefaultTargets = "Compile">  
       <Property appname = "HelloWorldCS"/>  
       <Item Type = "CSFile" Include = "consolehwcs1.cs"/>  
       <Target Name = "Compile">  
          <Task Name = "CSC" Sources = "@(CSFile)">  
             <OutputItem  TaskParameter = "OutputAssembly" Type = "EXEFile" Include = "$(appname).exe"/>  
          </Task> 
          <Message Text="The output file is @(EXEFile)"/>  
       </Target> 
    </Project> 

    This is (except for removing the extra crlf's and comments) exactly what I ran.  No material changes from what the Tutorial provided.  I get the following result.

    C:\PROJECTS\MSBuild>echo off  
    Microsoft (R) Build Engine Version 2.0.50727.3053  
    [Microsoft .NET Framework, Version 2.0.50727.3053]  
    Copyright (C) Microsoft Corporation 2005. All rights reserved.  
    C:\PROJECTS\MSBuild\consolehwcs1.proj(1,1): error MSB4041: The default XML namespace of the project 
    must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please 
    add xmlns=
    "http://schemas.microsoft.com/developer/msbuild/2003" to the <Project> element. If the 
    project has been authored in the old 1.0 
    or 1.2 format, please convert it to MSBuild 2003 format.
     
     
     

    As far as I know the project isn't in MSBuild 2003 format, but if I add the xmlns to the project element as suggested things get worse, with MSB4031 saying the MSBuildVersion attribute (which does not appear in the file) is deprecated and please remove it, followed by MSB4067 "The element <Property> beneath element <Project> is unrecognized".  Except that if you remove that, it then doesn't like the next element, <Item>, and so on.

    I hope somebody has a solution or a workaround for this.

    BTW, I am running on an XP workstation, and have VS2003 and VS2005 installed, along with .NET Fx versions up to 3.5 installed.  The batch file running the build above looks like:

    echo off  
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild consolehwcs1.proj  
    pause  
     


     

Antworten

  • Donnerstag, 25. September 2008 07:50Rong-Chun ZhangMSFT, ModeratorTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     BeantwortetEnthält Code

    Hi Cyberherbalist,

    In order to make MSBuild can build your project file, you need to make your project file as a project system format. See the following page:


    I have made some change of the project file and I can build it.

    <Project DefaultTargets = "Compile" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

            <PropertyGroup>

                    <Appname>HelloworldCS</Appname>

            </PropertyGroup>

            <ItemGroup>

                    <CSFile Include = "Program.cs"/>

            </ItemGroup>

            <Target Name = "Compile">

                    <CSC Sources = "@(CSFile)" TargetType="exe" OutputAssembly="$(Appname).exe"/>

                    <Message Text="The output file is $(Appname)"/>

            </Target>

    </Project>

    For more information, please check:
    http://msdn.microsoft.com/en-us/library/646dk05y.aspx
    http://msdn.microsoft.com/en-us/library/s5c8athz.aspx

    Best regards,
    Rong-Chun Zhang
    Please mark the replies as answers if they help and unmark if they don't.

Alle Antworten

  • Donnerstag, 25. September 2008 07:50Rong-Chun ZhangMSFT, ModeratorTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     BeantwortetEnthält Code

    Hi Cyberherbalist,

    In order to make MSBuild can build your project file, you need to make your project file as a project system format. See the following page:


    I have made some change of the project file and I can build it.

    <Project DefaultTargets = "Compile" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

            <PropertyGroup>

                    <Appname>HelloworldCS</Appname>

            </PropertyGroup>

            <ItemGroup>

                    <CSFile Include = "Program.cs"/>

            </ItemGroup>

            <Target Name = "Compile">

                    <CSC Sources = "@(CSFile)" TargetType="exe" OutputAssembly="$(Appname).exe"/>

                    <Message Text="The output file is $(Appname)"/>

            </Target>

    </Project>

    For more information, please check:
    http://msdn.microsoft.com/en-us/library/646dk05y.aspx
    http://msdn.microsoft.com/en-us/library/s5c8athz.aspx

    Best regards,
    Rong-Chun Zhang
    Please mark the replies as answers if they help and unmark if they don't.