目前我正在开发一个用于构建Windows窗体应用程序的NAnt脚本。构建NAnt脚本后,我收到错误
错误CS0246:找不到类型或命名空间名称“Form1” (您是否缺少using指令或程序集引用?)
建立失败
C:\程序 文件\楠\例子\ SampleWindowsApplication \ Sample.Build(24,10): 外部程序失败: C:\ Windows \ Microsoft.NET \ Framework \ v3.5 \ csc.exe(返回代码为1)“
有人可以建议解决这个问题吗?
请在下面找到我的代码。
<?xml version="1.0"?>
<project name="SampleWindowsApplication" default="run">
<property name="basename" value="SampleWindowsApplication"/>
<property name="debug" value="true"/>
<target name="clean">
<delete>
<fileset>
<include name="bin/${basename}-??.exe"/>
</fileset>
</delete>
</target>
<target name="build">
<mkdir dir="bin" />
<assemblyfileset id="Sample.assemblies">
<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\Assemblies\Sam.Grid.Base.dll" />
<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\Assemblies\Sam.Grid.Windows.dll" />
<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\Assemblies\Sam.Shared.Base.dll" />
<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\Assemblies\Sam.Shared.Windows.dll" />
<!--<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\Assemblies\System.Windows.Forms.dll" />-->
</assemblyfileset>
<csc target="exe" output="bin/${basename}.exe" debug="${debug}" >
<references refid="Sample.assemblies" />
<resources>
<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\licenses.licx"/>
</resources>
<sources>
<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\Program.cs"/>
</sources>
</csc>
</target>
<target name="run" depends="build">
<exec program="bin/${basename}-cs.exe" basedir="."/>
</target>
</project>
提前致谢。
答案 0 :(得分:0)
这通常是在您向解决方案添加新文件但不提交它们时导致的。 检查以确保已将Form1.cs和Form1.Designer.cs添加到源控件存储库。看起来您的项目文件已正确添加和提交,但某些源代码控制工具要求您在提交之前手动添加新文件。