Sdk: TargetFrameworkAttribute causing 'System' could not be found in the global namespace

Created on 26 Nov 2016  路  1Comment  路  Source: dotnet/sdk

I attempted a non-trivial dotnet migrate of the Google Cloud Libraries for .NET from preview2 to preview3 and have worked through several issues, but I'm currently stumped on https://github.com/ctaggart/google-cloud-dotnet/issues/4.

These generated files set the TargetFrameworkAttribute to use global::. The error messages seem to say that it may be causing problems.
image

// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETStandard,Version=v1.3", FrameworkDisplayName = "")]

The generated Google.CloudTools.Common.AsseblyInfo.cs, generated by Microsoft.NET.GenerateAssemblyInfo.targets doesn't use global::.

Error:

C:\Users\cameron\AppData\Local\Temp\.NETStandard,Version=v1.3.AssemblyAttributes.cs(4,20): error CS0400: The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?) [C:\Users\cameron\cs\google-cloud-dotnet\tools\Google.Cloud.ClientTesting\Google.Cloud.ClientTesting.csproj]
// Generated by the MSBuild WriteCodeFragment class.

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("Google.Cloud.ClientTesting")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("Package Description")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0-dont-release")]
[assembly: System.Reflection.AssemblyProductAttribute("Google.Cloud.ClientTesting")]
[assembly: System.Reflection.AssemblyTitleAttribute("Google.Cloud.ClientTesting")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
[assembly: System.Resources.NeutralResourcesLanguageAttribute("en")]

I'm I missing an assembly reference in this .csproj like the error says?

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
  <PropertyGroup>
    <TargetFrameworks>netstandard1.3;net451</TargetFrameworks>
    <AssemblyName>Google.Cloud.ClientTesting</AssemblyName>
    <AssemblyOriginatorKeyFile>../GoogleApiTools.snk</AssemblyOriginatorKeyFile>
    <SignAssembly>true</SignAssembly>
    <PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="**\*.cs" />
    <EmbeddedResource Include="**\*.resx" />
    <EmbeddedResource Include="compiler\resources\**\*" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk">
      <Version>1.0.0-alpha-20161125-1</Version>
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>
    <PackageReference Include="NETStandard.Library">
      <Version>1.6.1</Version>
    </PackageReference>
    <PackageReference Include="xunit">
      <Version>2.2.0-beta4-build3444</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
    <Reference Include="System" />
    <Reference Include="Microsoft.CSharp" />
  </ItemGroup>
  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
    <DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
  </PropertyGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Bug

Most helpful comment

This can happen if restore was not performed successfully. #540 tracks improving the diagnostics.

>All comments

This can happen if restore was not performed successfully. #540 tracks improving the diagnostics.

Was this page helpful?
0 / 5 - 0 ratings