dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.38k stars 10k forks source link

"Project file is incomplete. Expected imports are missing." - for project MonoSanityClient #16415

Closed ChristianWeyer closed 4 years ago

ChristianWeyer commented 6 years ago

Cloned the repo at commit 9fa187d63efbc05eb35e9a064b39335f01c1ab27

When loading the Blazor.SLN in VS I get this error: C:\sources\Blazor\samples\MonoSanityClient\MonoSanityClient.csproj : error : Project file is incomplete. Expected imports are missing.

Am I missing something? :-) Thanks.

SteveSandersonMS commented 6 years ago

That's very strange. I haven't seen that message. What version of VS and .NET Core are you using?

You need VS2017 15.7 Preview 1, and for .NET Core, it depends on whether you're working with Blazor.sln or an actual Blazor app created from the project templates.

If you're unsure how to create a new Blazor project using the project template, again you need VS 2017 15.7 Preview 1, and to install the Blazor VSIX from https://dotnet.myget.org/feed/blazor-dev/package/vsix/Microsoft.VisualStudio.BlazorExtension. Then it will appear in the File->New menu: when you create an ASP.NET Core web application, one of the subtypes (alongside Razor Pages and MVC) will be Blazor.

We're only a few days away from having a public 0.1.0 release of the Blazor so it will be simpler still then.

ChristianWeyer commented 6 years ago

Thanks mate, will check this out.

SteveSandersonMS commented 6 years ago

I'll mark this as closed since I think it's OK, but please let me know and/or reopen if there still appears to be a problem later.

ChristianWeyer commented 6 years ago

I am now running on VS 2017 15.7 Preview 1 and followed the steps for 'If you're working on Blazor.sln...'. Still for Blazor.sln I get this...

image

C:\sources\Blazor\samples\MonoSanityClient\MonoSanityClient.csproj : error : Project file is incomplete. Expected imports are missing.

Rick-Anderson commented 6 years ago

@ChristianWeyer This is not Blazor related. I'm working on this problem and will update this issue with a new GitHub issue. See this link for another customer that hit this error. cc @barrytang

Rick-Anderson commented 6 years ago

@ChristianWeyer can you verify the following file was installed?

{VSInstall}\Enterprise\MSBuild\Microsoft\VisualStudio\Managed\GeneralBrowseObject.xaml

AlanJacobsSandnet commented 6 years ago

I am getting something very similar when trying to create any ASP.NET Core project from in VS2017 (v15.6.3). VS creates a project file but fails to load it successfully reporting "Project file is incomplete. Expected imports are missing" in a popup message. The contents of the project file for a new ASP.NET Core Web Application project are as follows: `

netcoreapp2.0

`

This was first reported through the Razor pages tutorial as mentioned above by Rick Anderson - see this link Alan Jacobs

Rick-Anderson commented 6 years ago

@ChristianWeyer and @AlanJacobsSandnet can you verify the following file was installed?

{VSInstall}\Enterprise\MSBuild\Microsoft\VisualStudio\Managed\GeneralBrowseObject.xaml

AlanJacobsSandnet commented 6 years ago

Hi

I have the GeneralBrowseObject.xaml in the folder

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\Managed

I have attached a copy to this e-mail.

Kind Regards,

Alan Jacobs

From: Rick Anderson [mailto:notifications@github.com] Sent: 23 March 2018 18:11 To: aspnet/Blazor Blazor@noreply.github.com Cc: AlanJacobsSandnet alan.sandnet@btinternet.com; Mention mention@noreply.github.com Subject: Re: [aspnet/Blazor] "Project file is incomplete. Expected imports are missing." - for project MonoSanityClient (#279)

@ChristianWeyer and @AlanJacobsSandnet can you verify the following file was installed?

{VSInstall}\Enterprise\MSBuild\Microsoft\VisualStudio\Managed\GeneralBrowseObject.xaml

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/Blazor/issues/279#issuecomment-375754823 , or mute the thread https://github.com/notifications/unsubscribe-auth/Aj8-kovgbsmzU7QfiQjzi7FCiXwxv6EHks5thTrOgaJpZM4St8bw . https://github.com/notifications/beacon/Aj8-kq_aI7jODu0qv5ug6mhtcW7k2srOks5thTrOgaJpZM4St8bw.gif

bradphelan commented 6 years ago

Not specific to do with blazor but the same error nonetheless

Using

image

I also have C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\Managed\GeneralBrowserObject.xaml installed but am seeing the same issue.

Funny thing is that the project build via msbuild at the command line.

image

<Project Sdk="MSBuild.Sdk.Extras">
  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <None Remove="MultilingualResources\WeinCad.Controls.de.xlf" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Appccelerate.AsyncModule" Version="1.0.98" />
    <PackageReference Include="Appccelerate.Fundamentals" Version="2.8.0" />
    <PackageReference Include="Appccelerate.StateMachine" Version="4.4.0" />
    <PackageReference Include="Castle.Core" Version="3.2.0" />
    <PackageReference Include="Expression.Blend.Sdk" Version="1.0.2" />
    <PackageReference Include="Fody" Version="2.1.3" />
    <PackageReference Include="FSharp.Core" Version="4.2.3" />
    <PackageReference Include="FluentValidation" Version="7.1.1" />
    <PackageReference Include="I18N.Reactive" Version="4.1.2" />
    <PackageReference Include="LanguageExt.Core" Version="2.1.32" />
    <PackageReference Include="MahApps.Metro" Version="1.5.0" />
    <PackageReference Include="Microsoft.WindowsAPICodePack-Core" Version="1.1.0.2" />
    <PackageReference Include="Microsoft.WindowsAPICodePack-Shell" Version="1.1.0.0" />
    <PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
    <PackageReference Include="Ninject" Version="3.2.2.0" />
    <PackageReference Include="Ninject.Extensions.NamedScope" Version="3.2.0.0" />
    <PackageReference Include="Serilog" Version="2.6.0" />
    <PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
    <PackageReference Include="System.Interactive" Version="3.1.1" />
    <PackageReference Include="System.ValueTuple" Version="4.4.0" />
    <PackageReference Include="Unofficial.Blend.Interactivity" Version="1.0.0" />
    <PackageReference Include="Weingartner.Exceptional" Version="1.7.4-ci.2" />
    <PackageReference Include="Weingartner.Json.Migration" Version="311.0.0" />
    <PackageReference Include="Weingartner.ReactiveUI.Fody" Version="2.3.0-alpha.10" PrivateAssets="All" />
    <PackageReference Include="devDept.Eyeshot" Version="11.0.512" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="ReachFramework" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Safenet\Weingartner.Products\Weingartner.Products.fsproj" />
    <ProjectReference Include="..\Safenet\Weingartner.Safenet\Weingartner.Safenet.fsproj" />
    <ProjectReference Include="..\Weingartner.Controls\Weingartner.Controls.csproj" />
  </ItemGroup>
  <ItemGroup>
    <Resource Include="View\WeinLogo.gif" />
  </ItemGroup>
  <ItemGroup>
    <XliffResource Include="MultilingualResources\WeinCad.Controls.de.xlf" />
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Properties\Resources.de.resx" />
    <Compile Update="Properties\Resources.resx.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <EmbeddedResource Update="Properties\Resources.resx">
      <Generator>I18NReactive</Generator>
      <LastGenOutput>Resources.resx.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
</Project>

and

Directory.Build.props

<Project>

  <!-- Read https://msdn.microsoft.com/en-us/library/ms164309.aspx -->
  <PropertyGroup Label="Globals">
    <!-- Import this project to support WPF building in a .Net 461 SDK project -->
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
  </PropertyGroup>

  <!-- Ensure T4 is run correctory -->
  <ItemGroup>
    <None Include="**\*.tt">
      <Generator>TextTemplatingFileGenerator</Generator>
    </None>
  </ItemGroup>

  <!-- Ensure that if a FodyWeavers file is there then it is included -->
  <ItemGroup>
    <None Include="FodyWeavers.xml" Condition="Exists('FodyWeavers.xml')"/>
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="**\Resources.resx" LastGenOutput="Resources.resx.cs">
      <Generator>I18NReactive</Generator>
    </EmbeddedResource>
  </ItemGroup>

  <PropertyGroup>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>

 <PropertyGroup Label="MultilingualAppToolkit">
    <MultilingualAppToolkitVersion>4.0</MultilingualAppToolkitVersion>
    <MultilingualFallbackLanguage>en-US</MultilingualFallbackLanguage>
    <NeutralLanguage>en-Us</NeutralLanguage>
    <TranslationReport Condition="'$(Configuration)' == 'Release'">true</TranslationReport>
    <SuppressPseudoWarning Condition="'$(Configuration)' == 'Debug'">true</SuppressPseudoWarning>
  </PropertyGroup>

  <PropertyGroup >
    <NoWarn>NU1602</NoWarn>
  </PropertyGroup>

  <Import Project="$(MSBuildExtensionsPath)\Microsoft\Multilingual App Toolkit\Microsoft.Multilingual.ResxResources.targets" Label="MultilingualAppToolkit" Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\Multilingual App Toolkit\v$(MultilingualAppToolkitVersion)\Microsoft.Multilingual.ResxResources.targets')" />
  <Target Name="MATPrerequisite" BeforeTargets="PrepareForBuild" Condition="!Exists('$(MSBuildExtensionsPath)\Microsoft\Multilingual App Toolkit\Microsoft.Multilingual.ResxResources.targets')" Label="MultilingualAppToolkit">
    <Warning Text="$(MSBuildProjectFile) is Multilingual build enabled, but the Multilingual App Toolkit is unavailable during the build. If building with Visual Studio, please check to ensure that toolkit is properly installed." />
  </Target>

   <!-- Inject the git branch into the assembly metadata of all dlls -->
   <PropertyGroup>
       <GitBranch Condition="'$(GitBranch)' == ''">Not available</GitBranch>
   </PropertyGroup>
  <ItemGroup>
    <AssemblyAttribute Include="System.Reflection.AssemblyMetadata">
      <_Parameter1>GitBranch</_Parameter1>
      <_Parameter2>$(GitBranch)</_Parameter2>
    </AssemblyAttribute>
  </ItemGroup>

</Project>

and

global.json

{
    "msbuild-sdks": {
        "MSBuild.Sdk.Extras": "1.2.2"
    }
}
bradphelan commented 6 years ago

Update

I did a repair on the install of Visual Studio ( All is now well :) ) Maybe that helps you too.

davkean commented 6 years ago

Is everyone whom is having this trouble using MSBuild.Sdk.Extra? // cc @onovotny

Rick-Anderson commented 6 years ago

@davkean I've had several customers including @AlanJacobsSandnet report it. They were creating a Razor Pages web app with VS. See this link

davkean commented 6 years ago

https://github.com/aspnet/Blazor/blob/9fa187d63efbc05eb35e9a064b39335f01c1ab27/samples/MonoSanityClient/MonoSanityClient.csproj#L1 also uses a custom SDK. Are there examples that aren't custom SDKs?

davkean commented 6 years ago

I can imagine this happens when;

rynowak commented 6 years ago

I've seen this happen when using old SDKs that don't have the corresponding runtime installed, or using SDKs without the NuGet restorer.

ChristianWeyer commented 6 years ago

Sorry @Rick-Anderson - I was on vacation ;-) Yes, {VSInstall}\Enterprise\MSBuild\Microsoft\VisualStudio\Managed\GeneralBrowseObject.xaml is installed.

AlanJacobsSandnet commented 6 years ago

Also sorry for my silence over the Easter vacation... I have installed the VS Community (Preview 15.7.0 Preview 2) and am still experiencing this problem - even after repairing the installation this morning. For expediency I am now building my web site as a an ASP.NET web application and this release of VS is handling that OK. Do please let me know if you wish me to check out any of the suggestions from David Kean or Ryan Nowak above.

rynowak commented 6 years ago

@AlanJacobsSandnet - do you have dotnet on your %PATH%?

If you do a dotnet --list-sdks at the command line, what does it output?

This kind of problem can occur if you have an older version on the path that is preventing a newer build from being used

AlanJacobsSandnet commented 6 years ago

@Ryan Nowak

My path settings are as follows ( I added a new line after each ; for ease of reading)

PATH=

C:\Program Files\PHP\v7.1;

C:\ProgramData\Oracle\Java\javapath;

C:\Program Files\Common Files\Microsoft Shared\Windows Live;

C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;

C:\Perl64\site\bin;

C:\Perl64\bin;

C:\WINDOWS\system32;

C:\WINDOWS;

C:\WINDOWS\System32\Wbem;

C:\WINDOWS\System32\WindowsPowerShell\v1.0\;

C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;

C:\Program Files (x86)\Toshiba\Bluetooth Toshiba Stack\sys\;

C:\Program Files (x86)\Toshiba\Bluetooth Toshiba Stack\sys\x64\;

C:\Program Files (x86)\Windows Live\Shared;

C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;

C:\Program Files (x86)\Acronis\TrueImageHome\;

C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;

C:\Program Files\Microsoft SQL Server\110\Tools\Binn\Binn\??????;

C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;

C:\Program Files\IDM Computer Solutions\UltraEdit;

C:\Program Files (x86)\Common Files\Acronis\VirtualFile\;

C:\Program Files (x86)\Common Files\Acronis\VirtualFile64\;

C:\Program File;

C:\ProgramData\ComposerSetup\bin;

C:\Program Files\Git\cmd;

C:\Program Files\dotnet\;

C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;

"C:\Users\Alan\AppData\Local\Microsoft\WindowsApps;

D:\Drupal\PHP7";

C:\Users\Alan\AppData\Roaming\Composer\vendor\bin

If I try to run dotnet --list-sdks I get the following:

…which probably demonstrates that I don’t know how to use the dotnet command!

Alan

From: Ryan Nowak [mailto:notifications@github.com] Sent: 09 April 2018 21:20 To: aspnet/Blazor Blazor@noreply.github.com Cc: AlanJacobsSandnet alan.sandnet@btinternet.com; Mention mention@noreply.github.com Subject: Re: [aspnet/Blazor] "Project file is incomplete. Expected imports are missing." - for project MonoSanityClient (#279)

@AlanJacobsSandnet https://github.com/AlanJacobsSandnet - do you have dotnet on your %PATH%?

If you do a dotnet --list-sdks at the command line, what does it output?

This kind of problem can occur if you have an older version on the path that isn't being used.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/Blazor/issues/279#issuecomment-379881156 , or mute the thread https://github.com/notifications/unsubscribe-auth/Aj8-khWj2UKuNinjwfdyxMkXPJU0I4lCks5tm8J_gaJpZM4St8bw . https://github.com/notifications/beacon/Aj8-khWnFVh0FL6tpNVcIb_bXqBE7pZdks5tm8J_gaJpZM4St8bw.gif

AlanJacobsSandnet commented 6 years ago

Further to the above... This is the output for dotnet --info: .NET Command Line Tools (2.1.200-preview-007474)

Product Information: Version: 2.1.200-preview-007474 Commit SHA-1 hash: 06ce7628d3

Runtime Environment: OS Name: Windows OS Version: 10.0.16299 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.200-preview-007474\

Microsoft .NET Core Shared Framework Host

Version : 2.0.6

Build : 74b1c703813c8910df5b96f304b0f2b78cdf194d

rynowak commented 6 years ago

Version: 2.1.200-preview-007474

That would be the issue then! Blazor requires the newest preview of the dotnet CLI https://github.com/aspnet/Blazor#getting-started

AlanJacobsSandnet commented 6 years ago

OK – I’ve downloaded and installed the latest dotnet CLI 2.1.300 Preview and my dotnet command now has the --list-sdks option

The command output shows:

2.1.200-preview-007474 [C:\Program Files\dotnet\sdk]

2.1.300-preview1-008174 [C:\Program Files\dotnet\sdk]

BUT I am still unable to get VS to load the project file created from the ASP.NET Core Web Application template.

I have also built and successfully run the starter razor project using the latest installed dotnet command:

dotnet new razor -o RazorPagesMovie

cd RazorPagesMovie

dotnet run

I then tried to open the RazorPagesMovie.csproj file in VS but got the same behaviour: "Project file is incomplete. Expected imports are missing."

This feels to me like my VS setup is missing some important piece of configuration such as a PATH setting…

From: Ryan Nowak [mailto:notifications@github.com] Sent: 10 April 2018 16:58 To: aspnet/Blazor Blazor@noreply.github.com Cc: AlanJacobsSandnet alan.sandnet@btinternet.com; Mention mention@noreply.github.com Subject: Re: [aspnet/Blazor] "Project file is incomplete. Expected imports are missing." - for project MonoSanityClient (#279)

Version: 2.1.200-preview-007474

That would be the issue then! Blazor requires the newest preview of the dotnet CLI https://github.com/aspnet/Blazor#getting-started

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/Blazor/issues/279#issuecomment-380153657 , or mute the thread https://github.com/notifications/unsubscribe-auth/Aj8-kuUbB_lfdnAzp6jAFsnnajzxN2ecks5tnNaTgaJpZM4St8bw . https://github.com/notifications/beacon/Aj8-ko-gEByWOB7kl72O-Pvm58BT-sftks5tnNaTgaJpZM4St8bw.gif

Rick-Anderson commented 6 years ago

@rynowak writes:

That would be the issue then! Blazor requires the newest preview of the dotnet CLI

@AlanJacobsSandnet writes:

I am getting something very similar when trying to create any ASP.NET Core project from in VS2017

I've got several customers getting this error creating Razor Pages projects.

rynowak commented 6 years ago

I am getting something very similar when trying to create any ASP.NET Core project from in VS2017

If that's the case then, I think https://developercommunity.visualstudio.com/spaces/8/index.html is the right place to take this. Sorry I'm not able to help more.

AlanJacobsSandnet commented 6 years ago

@rynowak OK - will do! Thanks in any case for taking the time to try to resolve this. For expediency I am building my website now with ASP.Net Web Forms. I hope that once I have something working and deployed with that solution I can look at redoing the work using ASP Net Core.

Rick-Anderson commented 6 years ago

@AlanJacobsSandnet It's not an easy migration from Web Forms to Razor Pages. Razor Pages have alot of advantages over Web Forms. You could try uninstalling/reinstalling VS.

AlanJacobsSandnet commented 6 years ago

@Rick-Anderson - thanks for all your comments and suggestions as well. I am expecting in effect a total rewrite moving from Web Forms to Razor Pages - this will be a learning exercise for me. I'll try to post my experiences somewhere. Any migration exercise will be after the end of May. This problem with VS has persisted over the last several weeks through several install/uninstall/install cycles including a total uninstall of all previously installed versions and a move to the latest preview, 15.7.0 Release 2. I'll pursue this through https://developercommunity.visualstudio.com/spaces/8/index.html as Ryan advised.

ShadowDancer commented 6 years ago

I have two pcs with VS where blazor templates fail, however on third everything works.

Everything is updated and repair does not help.

urielgoncalves commented 6 years ago

I'm not sure that is a Blazor problem. I was with this problem opening an existing project. I solved this updating the global.json file for the correct .net core version.

image

image

AlanJacobsSandnet commented 6 years ago

@urielgoncalves: where will I find the global.json file on my machine?

VoodooSV commented 6 years ago

AlanJacobsSandnet global.json is in the solution directory

AlanJacobsSandnet commented 6 years ago

Thanks @VoodooSV but my solution directory contains just a solution file (.sln), a folder for each project in the solution and a hidden .vs folder. image

urielgoncalves commented 6 years ago

@AlanJacobsSandnet Sorry for the delay. I suggest you to look at this if you have not already. https://docs.microsoft.com/hu-hu/dotnet/core/tools/global-json

;)

ob1dev commented 6 years ago

I faced this today. I could open my VS Solution with 21 project. 20 (Class Library) got loaded and built successfully except of the one (ASP.NET Core Web App).

The reason was due to file global.json in VS Solution root

{
  "sdk": {
    "version": "2.0.2"
  }
}

where it requires .NET Core SDK 2.0.2, which I didn't have installed.

chucker commented 6 years ago

@AlanJacobsSandnet (and others who might run into this) in my case, the global.json was not in the directory with the .sln, but one layer above. It referenced .NET Core version 2.1.300. I ran dotnet --list-sdks to see which SDKs I actually have, and changed the file to 2.1.403. That fixed various weird errors in VS.

jenergm commented 5 years ago

I can imagine this happens when;

  • The SDK doesn't indirectly import Microsoft.Net.Sdk or Microsoft.CSharp.targets
  • The SDK isn't installed

This is true. My problem was solved when I've installed x86 version from .NET SDK Core. Just x64 doesn't work because my VS2017 is x86.

AlanJacobsSandnet commented 5 years ago

Finally solved this in my case when reinstalling VS2019 a few weeks ago. I discovered that my PATH setting had been damaged by installing (or perhaps uninstalling) another application. This is the offending fragment:

"C:\Users\Alan\AppData\Local\Microsoft\WindowsApps; D:\Drupal\PHP7"; C:\Users\Alan\AppData\Roaming\Composer\vendor\bin

It seems that the double quotes stop the parsing of the path settings and that the settings I needed for VS were further down the PATH list. Removing the two lines containing the double quotes allowed me to load the project file successfully.