Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9242539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:36:00+00:00 2026-06-18T08:36:00+00:00

Is it possible to change the msbuild version that is used by Visual Studio

  • 0

Is it possible to change the msbuild version that is used by Visual Studio 2008 when compiling projects?

I would like to set it to use msbuild 4.0.

The reason behind this is to be able to import the same .targets file used by our VS2012 projects for nuget packages restore. The projects cannot be upgraded to VS10+ because they are Smart Device projects.

I tried manually editing the original targets file but too many features are missing in msbuild 3.5 and I couldn’t work around them.

Update:

The original .targets file is also using the automatic download feature for the nuget.exe file, using a code task that is unsupported in the MSBuild 3.5, so this is something that should be taken into consideration.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:36:01+00:00Added an answer on June 18, 2026 at 8:36 am

    When you compile from Visual Studio you’re using devenv instead of msbuild. It would be great to see how devenv calls msbuild (but being VS a non open-source tool, we just can’t). So, I don’t think it is possible to do that. Maybe there’s another approach to do what are you’re trying to do.

    MSbuild v3.5 does not support dynamic task creation as MSbuild 4.0, but you can create customized tasks and import them.

    First, create a simple class library (I called it DownloadNuget2008.dll) containing the task to download nuget.exe (taken from nuget.targets):

    using System;
    using System.IO;
    using System.Net;
    using Microsoft.Build.Utilities;
    
    namespace DownloadNuget2008
    {
        public class DownloadNuget2008Task : Task
        {
            public string OutputFilename { get; set; }
    
            public override bool Execute()
            {
                try
                {
                    OutputFilename = Path.GetFullPath(OutputFilename);
    
                    Log.LogMessage("Downloading latest version of NuGet.exe...");
                    var webClient = new WebClient();
                    webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
    
                    return true;
                }
                catch (Exception ex)
                {
                    Log.LogErrorFromException(ex);
                    return false;
                }
            }
        }
    }
    

    I used to restore my NuGet packages on Visual Studio 2008 with the Exec Task below (edit your csproj/vbproj):

      <UsingTask AssemblyFile="$(SolutionDir)DownloadNuget2008.dll" TaskName="DownloadNuget2008Task" />
      <!-- Download NuGet.exe if it does not already exist -->
      <PropertyGroup>
        <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(SolutionDir)nuget.exe</NuGetExePath>
        <DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">true</DownloadNuGetExe>
      </PropertyGroup>
      <Target Name="_DownloadNuGet">
        <Message Text="Downloading nuget..." />
        <DownloadNuget2008Task OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
        <Message Text="Downloading nuget - done." />
      </Target>
      <!-- NuGet Packages Installation (Begin)  -->
      <Target Name="Install-Packages">
        <Exec Command="$(SolutionDir)nuget install $(ProjectDir)packages.config -o $(SolutionDir)packages" />
      </Target>
      <!-- NuGet Packages Installation (End)  -->
      <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
      <Target Name="BeforeBuild">
        <CallTarget Targets="_DownloadNuGet" />
        <CallTarget Targets="Install-Packages" />
      </Target>
    

    Then you will see on the output:

    Target BeforeBuild:
      Task "CallTarget"
        Target "_CheckForInvalidConfigurationAndPlatform" skipped. Previously built successfully.
        Target _DownloadNuGet:
          Task "Message"
            Downloading nuget...
          Done executing task "Message".
          Using "DownloadNuget2008Task" task from assembly "C:\marcos\Testes\NuGet2008\ConsoleApplication1\DownloadNuget2008.dll".
          Task "DownloadNuget2008Task"
            Downloading latest version of NuGet.exe...
          Done executing task "DownloadNuget2008Task".
          Task "Message"
            Downloading nuget - done.
          Done executing task "Message".
      Done executing task "CallTarget".
      Task "CallTarget"
        Target "_CheckForInvalidConfigurationAndPlatform" skipped. Previously built successfully.
        Target Install-Packages:
          Task "Exec"
            Command:
            C:\marcos\Testes\NuGet2008\ConsoleApplication1\nuget install C:\marcos\Testes\NuGet2008\ConsoleApplication1\ConsoleApplication1\packages.config -o C:\marcos\Testes\NuGet2008\ConsoleApplication1\packages
            Successfully installed 'elmah 1.2.2'.
          Done executing task "Exec".
      Done executing task "CallTarget".
    

    I understand you wish to use the same .targets file to both VS2012 and VS2008, but (as you said) there are many differences between MSBuild 3.5 and 4.0 so a specific approach is easier to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Change the Target Framework for all my projects in a Visual Studio
Possible Duplicate: Change language programatically in Android I would like to develop an Android
Is it possible to change C#'s built-in Vector3 struct to not use floating point
Is it possible to change SQL in a z/OS mainframe COBOL application so that
I'm working on a way to get MonoTouch projects to build in Visual Studio
Is possible change background-color on same td in fullcalendar? for example: I like have
Hi is possible to change the cells that contain specific value to another without
Possible Duplicate: Change custom color for Rectangle.Fill or Grid.Background I'm trying to dynamically set
Possible Duplicate: Change repo name in github I got some github repos that i
I have a few .net / C# projects that I'm building with MSBuild. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.