aspnet / Tooling

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

VS 2017 RC : How to define a multi framework project ? #877

Closed StefH closed 6 years ago

StefH commented 7 years ago

I've this csproj file:

<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
  <PropertyGroup>
    <TargetFrameworks>netstandard1.3</TargetFrameworks>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="**\*.cs" />
    <EmbeddedResource Include="**\*.resx" />
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
    <PackageReference Include="JetBrains.Annotations">
      <Version>10.2.1</Version>
    </PackageReference>
    <PackageReference Include="NETStandard.Library">
      <Version>1.6.1</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.NET.Sdk">
      <Version>1.0.0-alpha-20161104-2</Version>
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Newtonsoft.Json">
      <Version>9.0.1</Version>
    </PackageReference>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Which produces this error:

Restoring NuGet packages...
To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages during build.'
Error occurred while restoring NuGet packages: Invalid restore input. Invalid target framework 'unsupported'. Input files: C:\temp\ClassLibrary1\ClassLibrary1.csproj.
1>------ Rebuild All started: Project: ClassLibrary1, Configuration: Debug Any CPU ------
1>Build started 2016-11-23 07:43:43.
1>Target DispatchToInnerBuilds:
1>  Target _CheckForInvalidConfigurationAndPlatform:
1>    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(733,5): error : The OutputPath property is not set for project 'ClassLibrary1.csproj'.  Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='Debug'  Platform='AnyCPU'.  This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform.
1>  Done building target "_CheckForInvalidConfigurationAndPlatform" in project "ClassLibrary1.csproj" -- FAILED.
1>
1>  Done building project "ClassLibrary1.csproj" -- FAILED.
1>
1>Build FAILED.
mlorbetske commented 7 years ago

Any ideas @rrelyea? It looks like the failure is happening during restore

rrelyea commented 6 years ago

sorry didn't reply. Is this issue no longer important?

sayedihashimi commented 6 years ago

This is similar to an issue I ran into a while back. We had a bug when handling MSBuild files. If the MSBuild file contained items with Condition="" those would get stripped out. I think the bug has been fixed in the latest releases so I'm hoping this is no longer an issue.

The workaround for this is to add the following to the top of the MSBuild file.

 <!--/-:cnd -->