7

I am trying to set up a continuous integration server that is on Windows, that builds .net core applications, after installing only the .net core SDK from the .net core download site, without installing Visual Studio.

The error I get when I try to build is:

C:\dev\aaa.xproj(7,3): error MSB4019: The imported project 
 "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0
 \DNX\Microsoft.DNX.Props" was not found

I have googled and found complaints about this kind of error in earlier betas but I thought that the standalone .net core tools were supposed to work with just visual studio code (or indeed any editor) and with visual studio not installed, just the .net core standalone sdk.

Is there any technique to get this to work? Interestingly the error above occurred when I ran dotnet build from the solution root directory, like this:

msbuild /v:q  /t:Build /nologo /P:Configuration=Release MySolutionWithSevenProjectsInIt.sln

The above appears to require Visual Studio to be installed to build the whole solution, so I am guessing if I need a "solution build" step instead of an individual project build step, I need visual studio?

It's odd to me that this system has msbuild installed at all, all this computer has is the .net core sdk, and a "non working" (as above) msbuild.

Warren P
  • 65,725
  • 40
  • 181
  • 316
  • 3
    I think if you want to build w/o Visual Studio installed you're supposed to use dotnet and it's commands https://learn.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-build, because the dotnet cli tools are supposed to work w/o `*.sln/*.csproj/*.xproj` files, just based on project.json – Tseng Aug 04 '16 at 17:17
  • Interesting. There are also some crazy warnings even when building with dotnet on a machine without VS installed. It expects full set of C/C++ libraries like MFC and so on to exist. – Warren P Aug 04 '16 at 17:25
  • check this - http://stackoverflow.com/questions/34580599/building-a-net-core-app-via-command-line-so-that-it-works-on-a-machine-without – Sanket Aug 04 '16 at 17:52

1 Answers1

14

Yes, you can build modern .NET (not .NET Framework) applications without Visual Studio installed, on Windows, Mac and Linux.

You need the .NET SDK installed for your platform. Double check that you have the latest version:

dotnet --version
5.0.401

Then, go into your project directory (the folder that contains your .csproj file, or a .sln file) and run:

dotnet build

or, to build in Release mode:

dotnet build -c Release
Nate Barbettini
  • 51,256
  • 26
  • 134
  • 147
  • And don't try to use the MSBUILD that they installed for you. :-) – Warren P Aug 04 '16 at 19:05
  • Yep. I think this will need an update when they go back to msbuild with .net core. Not sure how that will work. "dotnet build" will invoke msbuild, I guess. – Warren P Aug 04 '16 at 19:46
  • I am also using the mac system and when i ran the dotnet build i got an error as follow, ........ visual studio/v15.0/Webapplications/microsoft.webaapplication.traget" was not fould. confirm that the path in the ddeclaration is correct, and that the file exists on disk... – Pravee Jan 15 '18 at 09:31
  • 1
    @Pravee You can only build cross-platform (.NET Core) projects on Mac. It sounds like that project might be an older (.NET Framework) project that will only build on Windows. See: https://stackoverflow.com/a/38064762/3191599 – Nate Barbettini Jan 15 '18 at 16:21
  • What about NuGet packages used? `The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)` – SerjG May 16 '19 at 20:42
  • @Sergey Are those NuGet packages listed in the `.csproj` file? If not, you need to add them. See https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-add-package – Nate Barbettini May 17 '19 at 05:22
  • @NateBarbettini yep. It was the issue with the referenced 4.6.1 project which referenced log4net. Converting to .NET Standard solved the problem. Sorry – SerjG May 18 '19 at 07:22