C# VS 2013 Error 02019: Invalid target type for /target: must specify 'exe', 'winexe', 'library', 'module', 'appcontainerexe' or 'winmdobj' CSC

社会主义新天地 提交于 2019-12-14 02:51:17

问题


I work on a website that uses various class libraries that are occasionally updated. One of the libraries is a sqlproj file and I believe it was made with VS2010. It is a dependency for other libraries and I'm not able to build/rebuild my solution because I keep getting this error, thus the DLLs will not generate. When I first open the project in VS2013, I get a migration report that opens in my browser. But the migration states that it's successful. When I try building the project, I get the error:

Error 1 02019: Invalid target type for /target: must specify 'exe', 'winexe', 'library', 'module', 'appcontainerexe' or 'winmdobj' CSC

I've tried to follow some of the recommendations on this question with essentially the same issue, but have been unsuccessful. Project fails to load due to missing SqlServer.targets file after upgrading to Visual Studio 2013 It seems like there are some unresolved streams in that question as well.

Any help would be great. Happy to provide more details and/or edit the question to make it more generalized. Thanks in advance.


回答1:


While none of the answers in Project fails to load due to missing SqlServer.targets file after upgrading to Visual Studio 2013 worked for me, and nobody else had ideas here on Stack Overflow, it turns out this was a bug related to backwards compatibility in Visual Studio 2013 and SSDTs (SQL Server Developer Tools). A comment in this forum solved my issue:

https://connect.microsoft.com/SQLServer/feedbackdetail/view/979839

Posted by bsclifton on 11/15/2014 at 7:18 AM

Had this issue too with the Community 2013 edition; Going to Tools->Extensions and Updates and updating "Microsoft SQL Server Update for database tooling" resolved the issue :)




回答2:


I had the same error message but on VS2017 in .sqlproj. It helped to add DefaultTargets argument in .targets file.

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="SetDacVersionToAssemblyVersion" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" />

  <Target Name="SetDacVersionToAssemblyVersion" AfterTargets="CoreCompile" Condition=" '$(EnableDacVersionFromAssembly)' == 'True' ">
    <GetAssemblyIdentity AssemblyFiles="$(IntermediateTargetFullFileName)">
      <Output TaskParameter="Assemblies" PropertyName="IntermediateTargetAssembly" />
    </GetAssemblyIdentity>
    <PropertyGroup>
      <DacVersion>$(IntermediateTargetAssembly.Split(',')[1].Split('=')[1])</DacVersion>
    </PropertyGroup>
  </Target>

</Project>



回答3:


Changed .sqlproj file with following as per the advised on other stack workflow thread. Worked for me.

$(MSBuildToolsPath) to $(MSBuildBinPath) in import tag



来源:https://stackoverflow.com/questions/32659292/c-sharp-vs-2013-error-02019-invalid-target-type-for-target-must-specify-exe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!