aspnet / Tooling

Issue tracker and info on Visual Studio tooling for ASP.NET
Other
256 stars 124 forks source link

Building a .NET Core project not working #512

Open Eilon opened 8 years ago

Eilon commented 8 years ago

Moved from: https://github.com/aspnet/Mvc/issues/4697 Opened by @chinookproject


I'm not sure if this is the right place to post this issue, but I'm having problem with building a .NET Core Web application. Visual Studio isn't generating any files in my bin folder.

I have this problem with every .NET Core Web Project that I create. Both with ASP.NET Core Web Application (.NET Core) and ASP.NET Core Web Application (.NET Framework). I then choose a default Web API project or a default Web Application project. But both don't produce any files in my bin folder when I built the project. Even though Visual Studio says the build completed successfully:

1>------ Rebuild All started: Project: EfCoreTest2, Configuration: Debug Any CPU ------
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

I don't have this problem when I create a ASP.NET Web application (.NET Framework) project. This only happens with the .NET Core projects.

I did a reinstall of VS2015. But that didn't solve my problem.

Is there anything else that I can try to fix this issue?

chinookproject commented 8 years ago

Just found out that I can compile my project through command line with dotnet build. That builds the project fine. But for some reason it's not building in Visual Studio.

sayedihashimi commented 8 years ago

TFS: 224851 I've added this to our internal TFS, we will reply back here soon.

balachir commented 8 years ago

@chinookproject, do you happen to have more than one .NET Core SDK installed? If you only have the Preview1 SDK, it should look like below.

image

Also, can you paste the full output from the Output Window? It should display the dotnet.exe command that's being invoked. image

chinookproject commented 8 years ago

@balachir I have exactly that one folder "1.0.0-preview-002702" in "C:\Program Files\dotnet\sdk".

I just did a rebuild all, this is the only thing in my output window:

1>------ Rebuild All started: Project: EfCoreTest2, Configuration: Debug Any CPU ------
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
balachir commented 8 years ago

@chinookproject , can you share the contents of your xproj file? Are you seeing this with new projects that you create as well, or only with existing project that you created using a previous version of the tooling?

chinookproject commented 8 years ago

I have this with new projects. I don't have any projects that were created with a previous version. So I can't tell you if existing projects made with older versions have the same problem.

The contents of my xproj is this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
  </PropertyGroup>
  <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
  <PropertyGroup Label="Globals">
    <ProjectGuid>be911c5a-9c7c-4300-a2d3-b6fab6e50c53</ProjectGuid>
    <RootNamespace>EfCoreTest2</RootNamespace>
    <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
    <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
  </PropertyGroup>
  <PropertyGroup>
    <SchemaVersion>2.0</SchemaVersion>
  </PropertyGroup>
  <Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

Could the problem be that I'm missing an environment variable?

BillHiebert commented 8 years ago

@chinookproject - can you turn on verbose logging in VS and send the output? Tools\Options\Project and Solutions\Build and Run. Set the Msbuild project build output verbosity to Diagnostic

chinookproject commented 8 years ago

@BillHiebert This is the log from my output window: build-output.txt

BillHiebert commented 8 years ago

This is very odd. It looks like msbuild did not run the DNX (poorly named) task which is the one which calls dotnet to do the build. And it doesn't show that the task was skipped.

@chinookproject Can you send me your C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.targets file? I can't imagine it differs from the shipped version but I also can't explain why the DNX task wasn't run.

chinookproject commented 8 years ago

@BillHiebert This is the Comomon Targets file. I changed it to a .txt extension, otherwise it wouldn't let me upload it.

Microsoft.DotNet.Common.Targets.txt

BillHiebert commented 8 years ago

Your file is wrong as it is missing about 6 lines of the build script. did you edit this file yourself? I think if you modify it, repair won't replace your edits. So the best way to fix this is to delete the file from disk and then repair Microsoft .NET Core RC2 - VS 2015 Tools Preview 1 (you don't need to repair all of visual studio). If that doesn't work, I can send you the correct file (though it makes me nervous that there could be other files wrong).

chinookproject commented 8 years ago

I deleted the Microsoft.DotNet.Common.targets file and did a repair, like you said. That fixed the problem. Although I have no idea why it was missing a few lines in that file. I never editted the file.

Thanks a lot for all the help. Now I can do a normal builds again through Visual Studio.

soda-sorcery commented 8 years ago

Thanks for this. I had the exact same issue. I'm not sure how to reproduce it. I had downloaded VS update 3 and then Tooling Preview 2 and then my build is VS stopped working.

muttech commented 8 years ago

I just saw this on another developer's machine; the 6 Dnx task element lines were missing. He didn't remember doing anything other than trying to Start with Debugging and noticing that his expected changes weren't there.

nelsonmorais commented 7 years ago

I had a similar problem, I was unable to build .xproj (Full Fwk) projects that referenced other projects on the solution. I was able to move forward after calling dotnet restore.

The dotnet restore still fails due to the fact that I have projects referenced in the ASP.Net Core (Full Fwk), but then the xproj build succeeds. Some extra info can be found here: http://www.hanselman.com/blog/HowToReferenceAnExistingNETFrameworkProjectInAnASPNETCore10WebApp.aspx

My guess is that the MSBuild DNX Task on C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.targets that depends on the C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Tasks.dll requires some packages that get restored only via dotnet restore and not by nuget restore (nuget 3.4.4)

So on my build agent I now have the nuget restore, dotnet restore (continue on error), and finally the .sln build.

It seems overkill but it works for now. I hope the new tooling comes fast to avoid this "mess".

zhenlee commented 7 years ago

I have a weird build error might related to this thread:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : Process is terminated due to StackOverflowException.

This is when I checked "Produce output on build" box, then the build failed on that project.

I have VS2015 update 3. Other devs in our team all had the same issue, so it might not be VS corruption in this case.

It only happens on the test projects (xunit).

Thanks!