I'm new to developing and my team leader asked me to solve this situation.

When compiling the solution with VS, every thing is OK. But when compiling with MSBuild, this line of code returns NULL value.

static DTE Dte;

Dte = serviceProvider.GetService(typeof(SDTE)) as DTE;

How can I solve this????

Thanks in advance.

This same question has been cross-posted multiple times:

http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/0ba199e9-e806-48bd-9b85-6f8668c732d4

http://stackoverflow.com/questions/11717613/how-can-i-get-a-dte-object-with-msbuild

http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/120c6cdf-5bba-4396-8ac8-7fe507ae879a

The answer: DTE and serviceProvider are Visual Studio constructs. You're not going to get them in MSBuild. Ask your team leader if he wants any headlight fluid or ID 10-T forms while you're out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.