Search code examples
.netvisual-studiomsbuildvisual-studio-2019csproj

Is there a problem with my references(paths) in .csproj


Because I have no programming skills a developer developed a website for me in VS2010. To become independent, I recently switched over to the latest (16.8.4) VS2019 Community. Now I want to remove version VS2010, but when I do so, version VS2019 reports build error problems. A Dutch forum poster assisted me to modify the .sln and .csproj files to run with VS2019 without VS2010. Unfortunately, we both seem to miss something to get the project to build with VS2019.

This is my present situation:

  1. A project folder containing all the files running perfectly with VS2010 So, the project itself is OK.
  2. A second project folder with modified .sln and .csproj files but with build errors in VS2019.
  3. I can run the VS2010 .csproj with VS2019, but only if VS2010 is not deïnstalled. So VS2019 also seem to be OK.

I notice missing references in .csproj VS2019 with respect to the VS2010 version. Just pasting (as to be expected) all the references from .csproj version VS2010 to VS2019 does not solve the problem. Can this be caused by wrong access paths or is there a different cause? (Maybe there are other links, but I don’t need all the stuff like Github, TourtoiseSVN and VisualSVN which are implemented in VS2010 at present)

I tried building a new .csproj fle but that appeared too difficult for me and so I now am running out of options. I followed these suggestions: How can I recover a corrupt .csproj file in Visual Studio 2010? and How to generate .csproj file in visual studio 2019? and did a lot of Googling and went through the posts regarding related .csproj questions. Actually I spent days on finding a solution. I also started an on-line training course at Udemy.com (Basic C#)

I would appreciate it if some is willing to go through my .csproj file to find the cause of my problem.

References of original working project in VS2010 Ultimate:  
0]  !
1]  System  
2]  System.Configuration    
3]  System.Data
4]  System.Data.DataSetExtensions   
5]  System.Drawing  
6]  System.EnterpriseServices   .
7]  System.Web
8]  System.Web.DynamicData  
9]  System.Web.Entity   
10] System.Web.Extensions   
11] System.Web.Services 
12] System.Xml
13] System.Xml.Linq

References of not working project in VS2019 Community:
0]  Zr= Analyzers
1]  System
2]  System.Configuration
3]  System.Data
4]  missing
5]  System.Drawing 
6]  System.EnterpriseServices
7]  System.Web
8]  System.Web.DynamicData
9]  System.Web.Entity
10] missing
11] System.Web.Services
12] System.Xml
13] missing

Here is my stripped .csproj file (for shorting reasons I took out most of the webpages entries)

'''

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>
    </ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{736AF0B8-36E1-4F7B-B2EB-DA11038B90FE}</ProjectGuid>
    <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Website</RootNamespace>
    <AssemblyName>Website</AssemblyName>
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    <TargetFrameworkProfile />
    <UseIISExpress>false</UseIISExpress>
    <SccProjectName> </SccProjectName>
    <SccLocalPath> </SccLocalPath>
    <SccAuxPath> </SccAuxPath>
    <SccProvider> </SccProvider>
    <Use64BitIISExpress />
    <IISExpressSSLPort />
    <IISExpressAnonymousAuthentication />
    <IISExpressWindowsAuthentication />
    <IISExpressUseClassicPipelineMode />
    <UseGlobalApplicationHostFile />
  </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>
  </PropertyGroup>
  <PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">16.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
  </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>
  </PropertyGroup>
  <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
  <ItemGroup>
    <Reference Include="System.Web.DynamicData" />
    <Reference Include="System.Web.Entity" />
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Web" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Web.Services" />
    <Reference Include="System.EnterpriseServices" />
  </ItemGroup>
   <ItemGroup>
    <Content Include="Master.Master" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="App_Code\" />
  </ItemGroup>
  <ItemGroup>
    <WCFMetadata Include="Connected Services\" />
  </ItemGroup>
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" />
  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
        <WebProjectProperties>
          <UseIIS>False</UseIIS>
          <AutoAssignPort>False</AutoAssignPort>
          <DevelopmentServerPort>6919</DevelopmentServerPort>
          <DevelopmentServerVPath>/</DevelopmentServerVPath>
          <IISUrl>
          </IISUrl>
          <NTLMAuthentication>False</NTLMAuthentication>
          <UseCustomServer>False</UseCustomServer>
          <CustomServerUrl>
          </CustomServerUrl>
         <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
  <!-- To  modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>  -->
</Project>

''' And the Msbuild output:

'''

Rebuild started...
1>------ Rebuild All started: Project: Website, Configuration: Release Any CPU ------
1>The "Configuration" property is a global property, and cannot be modified.
1>The "Platform" property is a global property, and cannot be modified.
1>Search paths being used for $(VSToolsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0;$(MSBuildProgramFiles32)\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)
1>Trying to import C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets using extensions path C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0
1>Property reassignment: $(WebProjectOutputDirInsideProjectDefault)="False" (previous value: "True") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets (21,5)
1>Property reassignment: $(WebProjectOutputDir)="_PublishedWebsites\Website" (previous value: "E:\JohnDoe\Homepage JohnDoe\Development\JohnDoe\Relatie Voeding & Gedrag\Trunk vs2019 Testversie") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets (33,5)
1>Property reassignment: $(PrepareForRunDependsOn)="
1>      
1>      ;
1>      CopySilverlightApplications;
1>      _CopyBinDeployableAssemblies;
1>    ;
1>      _CopyWebApplication;
1>      _BuiltWebOutputGroupOutput
1>    " (previous value: "
1>      ;
1>      CopySilverlightApplications;
1>      _CopyBinDeployableAssemblies;
1>    ") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets (42,5)
1>Property reassignment: $(CleanDependsOn)="
1>      
1>      ;
1>      CleanWebProjectOutputDir;
1>    ;
1>      
1>      ;
1>      CleanWebsitesPackage;
1>      CleanWebsitesWPPAllFilesInSingleFolder;
1>      CleanWebPublishPipelineIntermediateOutput;
1>    ;
1>    " (previous value: "
1>      ;
1>      CleanWebProjectOutputDir;
1>    ") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.targets (212,5)
1>Property reassignment: $(PipelineDependsOn)="
1>      
1>      ;
1>      BeforeBuild;
1>      BuildOnlySettings;
1>      ResolveReferences;
1>      PrepareResourceNames;
1>      ComputeIntermediateSatelliteAssemblies;
1>      GetCopyToOutputDirectoryItems;
1>      _SGenCheckForOutputs;
1>    ;
1>      AfterBuild;
1>    " (previous value: "
1>      ;
1>      BeforeBuild;
1>      BuildOnlySettings;
1>      ResolveReferences;
1>      PrepareResourceNames;
1>      ComputeIntermediateSatelliteAssemblies;
1>      GetCopyToOutputDirectoryItems;
1>      _SGenCheckForOutputs;
1>    ") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.targets (355,5)
1>Property reassignment: $(WebProjectOutputDirInsideProjectDefault)="True" (previous value: "False") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.targets (398,5)
1>Property reassignment: $(WebProjectOutputDirInsideProjectDefault)="False" (previous value: "True") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.targets (399,5)
1>Property reassignment: $(_UseDefaultLinkExtensionValue)="True" (previous value: "False") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.targets (450,5)
1>Property reassignment: $(_DestinationIisAppPhysicalPath)="E:\JohnDoe\Homepage JohnDoe\Development\JohnDoe\Relatie Voeding & Gedrag\Trunk vs2019 Testversie_deploy" (previous value: "") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.targets (511,5)
1>Property reassignment: $(WriteItemsToSourceManifestDependsOn)="
1>      ;
1>      
1>      ;
1>      AddDatabasesToSourceManifest;
1>    ;
1>      AddIisSettingAndFileContentsToSourceManifest;
1>    " (previous value: "
1>      ;
1>      AddDatabasesToSourceManifest;
1>    ") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.targets (3492,5)
1>Property reassignment: $(DbDacFxPreviewDependsOn)="
1>      
1>      ;
1>      GetMSDeployInstalledVersionPath;
1>    ;
1>      RemoteDbDacFxPreview;
1>    " (previous value: "
1>      ;
1>      GetMSDeployInstalledVersionPath;
1>    ") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.targets (4462,5)
1>Property reassignment: $(PipelineTransformPhaseDependsOn)="
1>      ;
1>      ;
1>      PipeLineCollectFilesPhase;
1>      TransformWebConfig;
1>      ProfileTransformWebConfig;
1>      InsertAdditionalWebCofigConnectionStrings;
1>      MarkWebConfigAssistFilesAsExclude;
1>    ;_TransformWebConfigForAzureAuthentication" (previous value: "
1>      ;
1>      ;
1>      PipeLineCollectFilesPhase;
1>      TransformWebConfig;
1>      ProfileTransformWebConfig;
1>      InsertAdditionalWebCofigConnectionStrings;
1>      MarkWebConfigAssistFilesAsExclude;
1>    ") at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing\ImportAfter\Microsoft.Web.AzureAD.Publishing.targets (17,5)
1>Property reassignment: $(OnBeforePipelineCollectFilesPhase)="
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

'''


Solution

  • With your csproj file in my side, you have lost the system default targets file.

    You should use this:

    <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
    
    
    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProductVersion>
        </ProductVersion>
        <SchemaVersion>2.0</SchemaVersion>
        <ProjectGuid>{E29977D2-D61E-4223-BE04-D56AD8F15C88}</ProjectGuid>
        <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>Website</RootNamespace>
        <AssemblyName>Website</AssemblyName>
        <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
        <TargetFrameworkProfile />
        <UseIISExpress>false</UseIISExpress>
        <SccProjectName>
        </SccProjectName>
        <SccLocalPath>
        </SccLocalPath>
        <SccAuxPath>
        </SccAuxPath>
        <SccProvider>
        </SccProvider>
        <Use64BitIISExpress />
        <IISExpressSSLPort />
        <IISExpressAnonymousAuthentication />
        <IISExpressWindowsAuthentication />
        <IISExpressUseClassicPipelineMode />
        <UseGlobalApplicationHostFile />
      </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>
      </PropertyGroup>
      <PropertyGroup>
        <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">16.0</VisualStudioVersion>
        <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
      </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>
      </PropertyGroup>
    
        
        <!--add this targets file to make msbuild find the Build,Rebild,Clean target-->
        <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
        
      <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
      <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
      <ItemGroup>
        <Reference Include="System.Web.DynamicData" />
        <Reference Include="System.Web.Entity" />
        <Reference Include="System" />
        <Reference Include="System.Data" />
        <Reference Include="System.Drawing" />
        <Reference Include="System.Web" />
        <Reference Include="System.Xml" />
        <Reference Include="System.Configuration" />
        <Reference Include="System.Web.Services" />
        <Reference Include="System.EnterpriseServices" />
      </ItemGroup>
      <ItemGroup>
        <Content Include="Master.Master" />
      </ItemGroup>
      <ItemGroup>
        <Folder Include="App_Code\" />
      </ItemGroup>
      <ItemGroup>
        <WCFMetadata Include="Connected Services\" />
      </ItemGroup>
      <!--<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" />-->
      <ProjectExtensions>
        <VisualStudio>
          <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
            <WebProjectProperties>
              <UseIIS>False</UseIIS>
              <AutoAssignPort>False</AutoAssignPort>
              <DevelopmentServerPort>6919</DevelopmentServerPort>
              <DevelopmentServerVPath>/</DevelopmentServerVPath>
              <IISUrl>
              </IISUrl>
              <NTLMAuthentication>False</NTLMAuthentication>
              <UseCustomServer>False</UseCustomServer>
              <CustomServerUrl>
              </CustomServerUrl>
              <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
            </WebProjectProperties>
          </FlavorProperties>
        </VisualStudio>
      </ProjectExtensions>
      <!-- To  modify your build process, add your task inside one of the targets below and uncomment it. 
           Other similar extension points exist, see Microsoft.Common.targets.
      <Target Name="BeforeBuild">
      </Target>
      <Target Name="AfterBuild">
      </Target>  -->
    </Project>
    

    This is the proj which I have tested in my VS2019 without any errors. If it did not work, you should share a sample of your project by a shared onedrive or a public github repository with us. Mostly the issue might have a conflict between your project files and proj file.