Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
169 views
in Technique[技术] by (71.8m points)

.net - 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)MicrosoftVisualStudiov$(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)WebApplicationsMicrosoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
  <Import Project="$(MSBuildExtensionsPath32)MicrosoftVisualStudiov16.0WebApplicationsMicrosoft.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)MicrosoftVisualStudiov16.0WebApplicationsMicrosoft.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 Studio2019CommunityMSBuildMicrosoftVisualStudiov16.0;$(MSBuildProgramFiles32)MSBuildMicrosoftVisualStudiov$(VisualStudioVersion)
1>Trying to import C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildMicrosoftVisualStudiov16.0WebApplicationsMicrosoft.WebApplication.targets using extensions path C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildMicrosoftVisualStudiov16.0
1>Property reassignment: $(WebProjectOutputDirInsideProjectDefault)="False" (previous value: "True") at C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildMicrosoftVisualStudiov16.0WebApplicationsMicrosoft.WebApplication.targets (21,5)
1>Property reassignment: $(WebProjectOutputDir)="_PublishedWebsitesWebsite" (previous value: "E:JohnDoeHomepage JohnDoeDevelopmentJohnDoeRelatie Voeding & GedragTrunk vs2019 Testversie") at C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildMicrosoftVisualStudiov16.0WebApplicationsMicrosoft.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 Studio2019CommunityMSBuildMicrosoftVisualStudiov16.0WebApplicationsMicrosoft.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 Studio2019CommunityMSBuildMicrosoftVisualStudiov16.0WebMicrosoft.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 Studio2019CommunityMSBuildMicrosoftVisualStudiov16.0WebMicrosoft.Web.Publishing.targets (355,5)
1>Property reassignment: $(WebPro

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)MicrosoftVisualStudiov$(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)WebApplicationsMicrosoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
  <Import Project="$(MSBuildExtensionsPath32)MicrosoftVisualStudiov16.0WebApplicationsMicrosoft.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)MicrosoftVisualStudiov16.0WebApplicationsMicrosoft.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...