你好。
首先我想对作者添加对 VB.NET 的支持表示感谢。
我想问一下是否可以在 VS Code/Code Runner 的 settings.json 中实现两个设置来指定 CSC 和 VBC 编译器目录路径(或者甚至更好,只是一个设置在哪里指定 MSBUILD 目录并假设 CSC 和 VBC 编译器都在那里,因为 Visual Studio 默认安装了这两个编译器)。
我认为强制用户将目录路径添加到 PATH 环境变量有点侵入性和麻烦,那么,从这个角度来看,这个设置的实现会更好(并且可移植)。
PS:对不起,我的英语不好。
感谢阅读!。
已经支持: https :
转到File
> Preferences
-> User Settings
,打开 settings.json,设置如下:
{
"code-runner.executorMapByFileExtension": {
".vb": "cd $dir && \"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\vbc.exe\" /nologo $fileName && $fileNameWithoutExt"
}
}
太感谢了。
请您确认一下这是否是正确的语法和设置位置?:
// Place your settings in this file to overwrite the default settings
{
// Default vs-code settings goes here...
// ...
// Code-runner extension: Compiler settings
"code-runner.executorMapByFileExtension": {
".cs": "cd $dir && \"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\csc.exe\" /nologo $fileName && $fileNameWithoutExt",
".vb": "cd $dir && \"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\vbc.exe\" /nologo $fileName && $fileNameWithoutExt"
}
}
那应该是对的。
对于cs文件,如果你已经安装了C#扩展,你需要设置如下:
{
"code-runner.executorMap": {
"csharp": "cd $dir && \"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\csc.exe\" /nologo $fileName && $fileNameWithoutExt"
},
"code-runner.executorMapByFileExtension": {
".vb": "cd $dir && \"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\vbc.exe\" /nologo $fileName && $fileNameWithoutExt"
}
}
我只想分享一个配置,以避免包含空格的文件名出现问题:
"code-runner.executorMap": {
"csharp": "cd $dir && \"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\csc.exe\" /nologo \"$fileName\" && \"$fileNameWithoutExt.exe\""
},
"code-runner.executorMapByFileExtension": {
".vb": "cd $dir && \"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\vbc.exe\" /nologo \"$fileName\" && \"$fileNameWithoutExt.exe\""
}
加上下面这个配置,如果你想有一个完整的C#和VB.NET编译经验,它会编译到C:WindowsTemp目录(避免生成垃圾可执行文件)并生成调试文件信息和Xml文档文件,它也引用了很常见的和重要的程序集,以节省时间和麻烦,它优化了一些调试编译器设置,使其更健壮地编译和分析(这与我在 Visual Studio 的项目文件 .vbproj/.csproj 中使用的引用和导入/使用配置相同默认情况下):
"code-runner.executorMap": {
"csharp": "cd $dir && \"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\csc.exe\" /nologo /preferreduilang:en-US /debug:full /warn:4 /doc:\"C:\\Windows\\Temp\\vs-code-runner.csharp.xml\" /reference:\"System.dll\",\"System.Core.dll\",\"System.Data.dll\",\"System.Data.DataSetExtensions.dll\",\"System.Deployment.dll\",\"System.DirectoryServices.AccountManagement.dll\",\"System.Drawing.dll\",\"System.Management.dll\",\"System.Net.dll\",\"System.Net.Http.dll\",\"System.Windows.Forms.dll\",\"System.Xml.dll\",\"System.Xml.Linq.dll\" /platform:anycpu /target:exe /out:\"C:\\Windows\\Temp\\vs-code-runner.csharp.exe\" \"$fileName\" && \"C:\\Windows\\Temp\\vs-code-runner.csharp.exe\""
},
"code-runner.executorMapByFileExtension": {
".vb": "cd $dir && \"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\vbc.exe\" /nologo /vbruntime+ /optionexplicit+ /optionstrict+ /optioninfer- /debug:full /verbose- /doc:\"C:\\Windows\\Temp\\vs-code-runner.vbnet.xml\" /reference:\"System.dll\",\"System.Core.dll\",\"System.Data.dll\",\"System.Data.DataSetExtensions.dll\",\"System.Deployment.dll\",\"System.DirectoryServices.AccountManagement.dll\",\"System.Drawing.dll\",\"System.Management.dll\",\"System.Net.dll\",\"System.Net.Http.dll\",\"System.Windows.Forms.dll\",\"System.Xml.dll\",\"System.Xml.Linq.dll\" /imports:\"Microsoft.VisualBasic\",\"Microsoft.Win32\",\"Microsoft.Win32.SafeHandles\",\"System\",\"System.Collections\",\"System.Collections.Concurrent\",\"System.Collections.Generic\",\"System.Collections.ObjectModel\",\"System.ComponentModel\",\"System.Data\",\"System.Diagnostics\",\"System.DirectoryServices.AccountManagement\",\"System.Drawing\",\"System.Globalization\",\"System.IO\",\"System.IO.MemoryMappedFiles\",\"System.Linq\",\"System.Linq.Expressions\",\"System.Management\",\"System.Net\",\"System.Reflection\",\"System.Resources\",\"System.Runtime.CompilerServices\",\"System.Runtime.InteropServices\",\"System.Runtime.Serialization\",\"System.Security.AccessControl\",\"System.Security.Permissions\",\"System.Security.Principal\",\"System.Text\",\"System.Text.RegularExpressions\",\"System.Threading\",\"System.Threading.Tasks\",\"System.Web\",\"System.Windows.Forms\",\"System.Xml\",\"System.Xml.Linq\",\"System.Xml.Serialization\" /platform:anycpu /target:exe /out:\"C:\\Windows\\Temp\\vs-code-runner.vbnet.exe\" \"$fileName\" && \"C:\\Windows\\Temp\\vs-code-runner.vbnet.exe\""
}
祝大家拥有美好的一天。
最有用的评论
我只想分享一个配置,以避免包含空格的文件名出现问题:
加上下面这个配置,如果你想有一个完整的C#和VB.NET编译经验,它会编译到C:WindowsTemp目录(避免生成垃圾可执行文件)并生成调试文件信息和Xml文档文件,它也引用了很常见的和重要的程序集,以节省时间和麻烦,它优化了一些调试编译器设置,使其更健壮地编译和分析(这与我在 Visual Studio 的项目文件 .vbproj/.csproj 中使用的引用和导入/使用配置相同默认情况下):
祝大家拥有美好的一天。