Reputation: 21
I am trying to configuring a SQL database project on my new machine(Windows 10) with the VS2019 Community version. the project is working fine on my old(window 10 and VS2019 community) machine. I downloaded the project from the repository and trying to build it. But the following errors.
Error CS0000 Invalid target type for /target: must specify 'exe', 'winexe', 'library', or 'module' projectName.sqlproj
Error 02019: Invalid target type for /target: must specify 'exe', 'winexe', 'library', or 'module' NexusDatabase CSC.
I've tried everything that is available on the internet without any luck. Can someone please help me to build the SQL project?
Upvotes: 2
Views: 1288
Reputation: 31
I had this problem.
For me, this problem was occurring in Visual Studio 2022 for an SQL database project. The project targets ".NET Framework 4.8". The project was created in an earlier version of Visual Studio, and originally targeted a much earlier version of ".NET Framework" (4.0 or earlier).
"CSC" is the C# compiler.
When I try to build / compile the project, the errors show. I click "View > Output" to see the "Output" window.
Build started...
------ Build started: Project: MyProjectName, Configuration: Debug Any CPU ------
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702,2008 /fullpaths /nostdlib+ /warn:4 /errorendlocation /preferreduilang:en-US /highentropyva+ /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\MyProjectName /ruleset:"C:\Program Files\Microsoft Visual Studio\2022\Community\Team Tools\Static Analysis Tools\\Rule Sets\AllRules.ruleset" /subsystemversion:6.00 /target:database /utf8output /langversion:7.3 MyCsFile.cs Properties\AssemblyInfo.cs "obj\Debug\.NETFramework,Version=v4.8.AssemblyAttributes.cs"
C:\Users\Owner\source\repos\MyRepoName\MyProjectName\CSC: Error: CS2019: Invalid target type for /target: must specify 'exe', 'winexe', 'library', or 'module'
Done building project "MyProjectName.sqlproj" -- FAILED.
Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
The window "Output" will show the command that Visual Studio used when it tried to build / compile the project. For me, this is line 3 (above).
The error CS0000: Invalid target type for /target: must specify 'exe', 'winexe', 'library', or 'module'
tells me that the issue is that the compiler does not accept the part /target:database
from line 3 (above).
I can change this from "database" to "library" by doing the following.
Open the ".sqlproj" file (for me this is MyProjectName.sqlproj
) in notepad (I tried to do this in Visual Studio, but it was unsuccessful, so use notepad). Find the part the says:
<OutputType>Database</OutputType>
, change this to <OutputType>Library</OutputType>
. Save. Restart Visual Studio. Click "Build > Rebuild". Now it compiles, but it generates a DLL instead of SQL or database.
I also verified that Microsoft SQL Server Data Tools (SSDt) was installed. This did not solve the problem.
I tried switching from Visual Studio Community 2022 to Visual Studio Community 2019. This did not solve the problem.
Rolan's answer to https://stackoverflow.com/a/28813869/17646313
Within the sqlproj file, nested within the <Project>
element, add specific IMPORT elements.
Upvotes: 1