1

The common method for embedding XML files in a C# executable is to simply add it to the project in Visual Studio, then change its "Build Action" property to "Embedded Resource."

This works very well in Visual Studio, but how can the same result be accomplished with only the command line?

2
  • Would using MSBuild from command line work? Commented Jul 23, 2012 at 22:52
  • @AlexeiLevenkov - I don't know, I haven't used it. Do you have any more info? Commented Jul 23, 2012 at 22:53

2 Answers 2

2

MSBuild is more generic tool to build complex project that have more than cople .CS files. MSBuild is command line equivalent of building .CSProj in Visual Studio.

To build solution with MSBuild:

  • launch "Visual Studio Command Prompt" (or run command file that sets environment VS variables)
  • check if msbuild is correctly in PATH: `msbuild /?"
  • specify .Csproj as argument to build it : msbuild MyProject.csproj.
Sign up to request clarification or add additional context in comments.

3 Comments

What if msbuild isn't available?
@derekerdmann, Reinstall .Net Framework? (normal location is something like \Windows\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe depending on version/bitness)
No, I mean that I can't use msbuild. It's not that it's missing; it's that the build system doesn't use it (as far as I know).
2

Turns out the solution was to use the /res argument when compiling, with this syntax:

/res:MyFile.xml,MyNamespace.MyFile.xml

Where MyFile.xml is the file in the source directory, and MyNamepace.MyFile.xml is the name that's used when calling GetManifestResourceStream().

2 Comments

Can you elaborate? Is this a parameter while building from MSBuild?
No, this is a parameter to the C# compiler

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.