0

I want to migrate packages.config to packagesReference. I have solution consisting of 46 projects, For ASP.NET it's not possible to migrate whole .SLN so we need to go one project by one using this workaround -> packageReference issue for asp.net

I have succeed. But when I try to build this project, I'm getting multiple errors like below:

The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

Seems like project doesn't see included NuGets. Maybe we need to upgrade it to new csproj? It's still in old 2013/2015 version.

First property Group looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>
    </ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
    <ProjectGuid>{C186BDC8-3606-4C75-B807-3389C0160030}</ProjectGuid>
    <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>ProjectName</RootNamespace>
    <AssemblyName>ProjectName</AssemblyName>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <MvcBuildViews>false</MvcBuildViews>
    <UseIISExpress>true</UseIISExpress>
    <IISExpressSSLPort />
    <IISExpressAnonymousAuthentication />
    <IISExpressWindowsAuthentication />
    <IISExpressUseClassicPipelineMode />
    <SccProjectName>SAK</SccProjectName>
    <SccLocalPath>SAK</SccLocalPath>
    <SccAuxPath>SAK</SccAuxPath>
    <SccProvider>SAK</SccProvider>
    <UseGlobalApplicationHostFile />
    <Use64BitIISExpress />
    <TargetFrameworkProfile />
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <DocumentationFile>
    </DocumentationFile>
    <ExcludeGeneratedDebugSymbol>false</ExcludeGeneratedDebugSymbol>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <DocumentationFile>content\doc\api-doc.xml</DocumentationFile>
    <ExcludeGeneratedDebugSymbol>false</ExcludeGeneratedDebugSymbol>
    <FilesToIncludeForPublish>AllFilesInTheProject</FilesToIncludeForPublish>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="CSharpSDK, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\Core\Libs\CSharpSDK.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System" />
    <Reference Include="System.ComponentModel.Composition" />
    <Reference Include="System.Data" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Data.OracleClient" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.IdentityModel" />
    <Reference Include="System.identitymodel.services" />
    <Reference Include="System.IO.Compression" />
    <Reference Include="System.Net" />
    <Reference Include="System.Numerics" />
    <Reference Include="System.Runtime.Caching" />
    <Reference Include="System.Security" />
    <Reference Include="System.ServiceModel" />
    <Reference Include="System.ServiceProcess" />
    <Reference Include="System.Transactions" />
    <Reference Include="System.Web.DynamicData" />
    <Reference Include="System.Web.Entity" />
    <Reference Include="System.Web.ApplicationServices" />
    <Reference Include="System.ComponentModel.DataAnnotations" />
    <Reference Include="System.Web.Extensions" />
    <Reference Include="System.Web" />
    <Reference Include="System.Web.Abstractions" />
    <Reference Include="System.Web.Routing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Runtime.Serialization" />
    <Reference Include="System.Net.Http.WebRequest">
    </Reference>
    <Reference Include="System.Xml.Linq" />
    <Reference Include="WindowsBase" />
  </ItemGroup>

Next item group is ProjectReference and other controller,content etc.

Thanks, Rafal

Ace
  • 53
  • 7
  • It looks like you didn't include nuget reference in new sdk csproj. Please share csproj of project where you see this error. – Lukasz Szczygielek Nov 25 '20 at 12:17
  • Hey @Hostel, thanks for reaching out. I have just edited my post. This issue here is for Web project and as I got to known later, it is not possible (and worth) to migrate it to packageReference as we can't edit web.config later on. But still it would be beneficial to know why it's failing :) – Rafał Głębocki Nov 25 '20 at 22:27
  • Please also show how your new sdk csproj looks like. – Lukasz Szczygielek Nov 25 '20 at 22:41
  • @Hostel, this is csproj after migration. I have just migrated to packageReference from VS. Should I also move csproj to vs2017 version? – Rafał Głębocki Nov 28 '20 at 10:41
  • 1
    Sorry I misunderstood your question. In your example I don't see any `PackageReference` node, `Newtonsoft` comes from nuget, so that's why you see error. – Lukasz Szczygielek Nov 29 '20 at 17:10
  • Might be. Basically it turns out that we shoudn't migrate Web projects to packageReferences because of issues with WebConfig and running scripts. – Rafał Głębocki Dec 02 '20 at 13:22

0 Answers0