如何阻止 VS2015 将 my.csproj 转换为 .sqlproj?

How to stop VS2015 from converting my.csproj into .sqlproj?

我有一个旧的解决方案,我正在尝试使用其中的当前项目构建一个更新的解决方案。其中一个项目是 SQLUtils,它只包含 .cs 文件,它的 Target framework.NET Framework 2.0.

在旧的解决方案中,它是一个常规的 C# Class 库项目,但是当我将它添加到我的新解决方案中时,它变成了 .sqlproj 并且在构建它时出现错误。

我尝试像编辑旧的那样编辑新的 .sln,但这没有任何区别。

我看了https://social.msdn.microsoft.com/Forums/sqlserver/en-US/38113dcd-caaa-4704-ad69-d7ce774d2916/sql-server-data-tools-september-edition-migration-issues-vs2010?forum=ssdt

并在 https://social.msdn.microsoft.com/Forums/sqlserver/en-US/0f537da4-9d61-45bf-8778-102eae9d4b83/csproj-to-sqlproj-migration-in-vs2012-with-ssdt?forum=ssdt

但他们并没有完全解决它,你知道 MSDN...

附加信息: 解决方案文件:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "BO 25.7.17", "BO 25.7.17", "{5C12D821-9F39-4C47-A888-DD65E5CD6464}"
    ProjectSection(WebsiteProperties) = preProject
        SccProjectName = "SAK"
        SccAuxPath = "SAK"
        SccLocalPath = "SAK"
        SccProvider = "SAK"
        TargetFrameworkMoniker = ".NETFramework,Version%3Dv2.0"
        ProjectReferences = "{f977dcec-ed6c-485f-ab12-1fe31b7cbc5c}|Logic.dll;"
        Debug.AspNetCompiler.VirtualPath = "/localhost_61694"
        Debug.AspNetCompiler.PhysicalPath = "..\..\..\..\..\..\TFS\StyleRiver\BO\BO 25.7.17\"
        Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_61694\"
        Debug.AspNetCompiler.Updateable = "true"
        Debug.AspNetCompiler.ForceOverwrite = "true"
        Debug.AspNetCompiler.FixedNames = "false"
        Debug.AspNetCompiler.Debug = "True"
        Release.AspNetCompiler.VirtualPath = "/localhost_61694"
        Release.AspNetCompiler.PhysicalPath = "..\..\..\..\..\..\TFS\StyleRiver\BO\BO 25.7.17\"
        Release.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_61694\"
        Release.AspNetCompiler.Updateable = "true"
        Release.AspNetCompiler.ForceOverwrite = "true"
        Release.AspNetCompiler.FixedNames = "false"
        Release.AspNetCompiler.Debug = "False"
        VWDPort = "61694"
        SlnRelativePath = "..\..\..\..\..\..\TFS\StyleRiver\BO\BO 25.7.17\"
    EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logic", "Logic\Logic.csproj", "{F977DCEC-ED6C-485F-AB12-1FE31B7CBC5C}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Debug|Mixed Platforms = Debug|Mixed Platforms
        Debug|x64 = Debug|x64
        Debug|x86 = Debug|x86
        Release|Any CPU = Release|Any CPU
        Release|Mixed Platforms = Release|Mixed Platforms
        Release|x64 = Release|x64
        Release|x86 = Release|x86
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {5C12D821-9F39-4C47-A888-DD65E5CD6464}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {5C12D821-9F39-4C47-A888-DD65E5CD6464}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {5C12D821-9F39-4C47-A888-DD65E5CD6464}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
        {5C12D821-9F39-4C47-A888-DD65E5CD6464}.Debug|x64.ActiveCfg = Debug|Any CPU
        {5C12D821-9F39-4C47-A888-DD65E5CD6464}.Debug|x64.Build.0 = Debug|Any CPU
        {5C12D821-9F39-4C47-A888-DD65E5CD6464}.Debug|x86.ActiveCfg = Debug|Any CPU
        {5C12D821-9F39-4C47-A888-DD65E5CD6464}.Release|Any CPU.ActiveCfg = Debug|Any CPU
        {5C12D821-9F39-4C47-A888-DD65E5CD6464}.Release|Any CPU.Build.0 = Debug|Any CPU
        {5C12D821-9F39-4C47-A888-DD65E5CD6464}.Release|Mixed Platforms.ActiveCfg = Debug|Any CPU
        {5C12D821-9F39-4C47-A888-DD65E5CD6464}.Release|x64.ActiveCfg = Debug|Any CPU
        {5C12D821-9F39-4C47-A888-DD65E5CD6464}.Release|x64.Build.0 = Debug|Any CPU
        {5C12D821-9F39-4C47-A888-DD65E5CD6464}.Release|x86.ActiveCfg = Debug|Any CPU
        {F977DCEC-ED6C-485F-AB12-1FE31B7CBC5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {F977DCEC-ED6C-485F-AB12-1FE31B7CBC5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {F977DCEC-ED6C-485F-AB12-1FE31B7CBC5C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
        {F977DCEC-ED6C-485F-AB12-1FE31B7CBC5C}.Debug|x64.ActiveCfg = Debug|x64
        {F977DCEC-ED6C-485F-AB12-1FE31B7CBC5C}.Debug|x64.Build.0 = Debug|x64
        {F977DCEC-ED6C-485F-AB12-1FE31B7CBC5C}.Debug|x86.ActiveCfg = Debug|Any CPU
        {F977DCEC-ED6C-485F-AB12-1FE31B7CBC5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {F977DCEC-ED6C-485F-AB12-1FE31B7CBC5C}.Release|Any CPU.Build.0 = Release|Any CPU
        {F977DCEC-ED6C-485F-AB12-1FE31B7CBC5C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
        {F977DCEC-ED6C-485F-AB12-1FE31B7CBC5C}.Release|x64.ActiveCfg = Release|x64
        {F977DCEC-ED6C-485F-AB12-1FE31B7CBC5C}.Release|x64.Build.0 = Release|x64
        {F977DCEC-ED6C-485F-AB12-1FE31B7CBC5C}.Release|x86.ActiveCfg = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
    GlobalSection(TeamFoundationVersionControl) = preSolution
        SccNumberOfProjects = 2
        SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
        SccTeamFoundationServer = http://gpnt049:8080/tfs/zap%20market%20-%20zap%20travel
        SccWebProject0 = true
        SccProjectUniqueName0 = BO\u002025.7.17
        SccProjectName0 = BO\u002025.7.17
        SccAuxPath0 = http://gpnt049:8080/tfs/zap%20market%20-%20zap%20travel
        SccLocalPath0 = BO\u002025.7.17
        SccProvider0 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
        SccProjectEnlistmentChoice0 = 2
        SccProjectUniqueName1 = Logic\Logic.csproj
        SccProjectName1 = Logic
        SccAuxPath1 = http://gpnt049:8080/tfs/zap%20market%20-%20zap%20travel
        SccLocalPath1 = Logic
        SccProvider1 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
    EndGlobalSection
EndGlobal

.csproj:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectTypeGuids>{c252feb5-a946-4202-b1d4-9916a0590387};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <ProductVersion>8.0.50727</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{80A3D07F-863D-4E34-A5D4-8587A201629E}</ProjectGuid>
    <OutputType>Library</OutputType>
    <NoStandardLibraries>false</NoStandardLibraries>
    <AssemblyName>SQLUtils</AssemblyName>
    <RootNamespace>SQLUtils</RootNamespace>
    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
    <FileUpgradeFlags>40</FileUpgradeFlags>
    <OldToolsVersion>4.0</OldToolsVersion>
    <UpgradeBackupLocation>C:\TFS\StyleRiver\StyleRiver 24.7.17\Backup1\</UpgradeBackupLocation>
    <ConnectionString />
    <PublishUrl>publish\</PublishUrl>
    <Install>true</Install>
    <InstallFrom>Disk</InstallFrom>
    <UpdateEnabled>false</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateInterval>7</UpdateInterval>
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
    <UpdatePeriodically>false</UpdatePeriodically>
    <UpdateRequired>false</UpdateRequired>
    <MapFileExtensions>true</MapFileExtensions>
    <ApplicationRevision>0</ApplicationRevision>
    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
    <IsWebBootstrapper>false</IsWebBootstrapper>
    <UseApplicationTrust>false</UseApplicationTrust>
    <BootstrapperEnabled>true</BootstrapperEnabled>
    <SccProjectName>
    </SccProjectName>
    <SccLocalPath>
    </SccLocalPath>
    <SccAuxPath>
    </SccAuxPath>
    <SccProvider>
    </SccProvider>
    <TargetFrameworkProfile />
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <WarningLevel>4</WarningLevel>
    <DeployCode>true</DeployCode>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugSymbols>false</DebugSymbols>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
    <DefineConstants>TRACE</DefineConstants>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(MSBuildBinPath)\SqlServer.targets" />
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.XML" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Concat.cs" />
    <Compile Include="ConcatDistinct.cs" />
    <Compile Include="Encryption.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="SqlRegEx.cs" />
    <Compile Include="ToUrlCompatible.cs" />
  </ItemGroup>
  <!-- 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>
  -->
  <ItemGroup>
    <None Include="Test Scripts\Test1.sql" />
  </ItemGroup>
  <ItemGroup>
    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
      <Visible>False</Visible>
      <ProductName>Windows Installer 3.1</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
  </ItemGroup>
</Project>

每次添加项目时都会创建一个名为 "UpgradeLog.htm" 的文件。
这是它的样子:

引用代码项目中的以下文章

List of Visual Studio Project Type GUIDs

There isn't an easy way to change the type of a project in Visual Studio project once it is created; for example changing a C# Class Library into a Portable Class Library (PCL). Knowing these GUIDs will allow you to edit project files like .csproj and .vbproj to easily change a project type in cases where Visual Studio will not allow using the GUI.

让我们看一下上面显示的代码片段中的项目类型 GUID

解决方案文件:

{E24C65DC-7377-472B-9ABA-BC803B73C61A} = Web Site Project
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} = C# Project

查看解决方案文件时提到了上述项目类型。所有其他 GUID 都是项目本身的唯一项目 ID。

.csproj: 具有以下项目类型 GUID

<ProjectTypeGuids>{c252feb5-a946-4202-b1d4-9916a0590387};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

其中项目类型GUIDs

{c252feb5-a946-4202-b1d4-9916a0590387} = Visual Database Tools
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} = C# Project

再次引用文章,替换与OP相关的代码

Notes

  1. You will find these properties as a <ProjectTypeGuids> element in the project file, not to be confused with <ProjectGuid> which is a unique identifier for your project.
  2. Some GUIDs are used in combination. For example <ProjectTypeGuids>{c252feb5-a946-4202-b1d4-9916a0590387};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> describes a Visual Database Tools library in C#.

我建议您在尝试打开 .csproj 项目文件之前尝试 remove/replacing Visual Database Tools 项目类型 Guid {c252feb5-a946-4202-b1d4-9916a0590387}在较新的 IDE

.NET 2.0 中有一个 功能,即自动创建 UpgradeLog.htm 文件。

要防止自动创建此文件,请执行以下步骤:

  • 取消选中工具->选项下的"Always show solution"->项目和解决方案->一般并添加您的解决方案.

  • 或者,只需从根目录中删除 .htm 文件即可完美运行。

  • 或者,将您的项目托管到本地而不是直接托管到服务器。

我通过结合 Camilo Tervento 评论和 Nkosi 回答设法解决了这个问题。
我从cs.proj中删除:

<Import Project="$(MSBuildBinPath)\SqlServer.targets" />

我从 <ProjectTypeGuids> 中删除了:

c252feb5-a946-4202-b1d4-9916a0590387

Visual Database Tools 项目的类型,如前面提到的 Nkosi
现在项目编译正常,没有任何错误,谢谢!