How to build rptproj using C#

752 views Asked by At

I want to build all my reports project and copy .rdl files to other location.

I am using MSBuild.Engine for same.

 Engine engine = new Engine();

            // Point to the path that contains the .NET Framework 2.0 CLR and tools
            engine.BinPath = @"c:\windows\microsoft.net\framework\v2.0.50727";


            // Instantiate a new FileLogger to generate build log
            FileLogger logger = new FileLogger();

            // Set the logfile parameter to indicate the log destination
            logger.Parameters = @"logfile=C:\temp\build.log";

            // Register the logger with the engine
            engine.RegisterLogger(logger);

            // Build a project file 
            bool success = engine.BuildProjectFile(@"xyz.rptproj");

            //Unregister all loggers to close the log file
            engine.UnregisterAllLoggers();

            if (success)
                Console.WriteLine("Build succeeded.");
            else
                Console.WriteLine(@"Build failed. View C:\temp\build.log for details");

Also I am getting error that cannot build this project. Error log says below:

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.

Can someone help or suggest me?

Thanks

1

There are 1 answers

1
Mike On

This may not be the best answer, but you could create a blank class library project in visual studio, for build and install purposes. Add each RDL file to the project, they can exist on another project so the link (file path in the .csproj) to the file can point to where they actually live on another project in source control. Mark each file as "content" and to "copy always". After that is saved and part of a solution, you can call MSbuild to build that project and use the content output of the build, or this can also be used in an installer to use the content output from the project and specify where you want the install folder to live.