Mac 上的 .NET 开发技巧

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44601/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 09:43:54  来源:igfitidea点击:

.NET Development on a Mac Tips

.netmacosvmwarevirtualization

提问by Andrew Burns

I have just got a MacBook Pro and have been using it (+Fusion) to develop on for about a month now. The purpose of this question is similar to Hidden Features of C#; to become a how-to of tips and trick for windows development on a mac.

我刚买了一台 MacBook Pro,并且已经使用它 (+Fusion) 进行了大约一个月的开发。这个问题的目的类似于C# 的 Hidden Features;成为 Mac 上 Windows 开发的技巧和窍门。

I should clarify that I am aware of boot camp but do not use it (nor do I have any interest to), hence my use of steady state to make sure nothing happens to my OS partition without my knowledge. However; as Sara pointed out, Apple makes great hardware and I absolutely LOVEthe form factor of my MBP so for someone who is looking for a windows only laptop a mac with boot camp should not be overlooked as the hardware is amazing.

我应该澄清一下,我知道新兵训练营但不使用它(我也没有任何兴趣),因此我使用稳定状态来确保我的操作系统分区在我不知情的情况下不会发生任何事情。然而; 正如 Sara 指出的那样,Apple 制造了出色的硬件,我非常喜欢MBP 的外形,因此对于正在寻找仅 Windows 笔记本电脑的人来说,不应忽视带有新兵训练营的 Mac,因为硬件很棒。

My environment is as follows
* MacBook Pro 15" 2.4Ghz 2GB RAM (Going to upgrade to 4GB soon)
* VMWare Fusion 2.0 Beta
* Windows XP Pro SP3 (Slipstreamed BEFORE install)

我的环境如下
* MacBook Pro 15" 2.4Ghz 2GB RAM(即将升级到 4GB)
* VMWare Fusion 2.0 Beta
* Windows XP Pro SP3(安装前滑流)

Tips:
* Use Windows Steady State to keep OS consistent
* Use svn+ssh to connect to the mac for small repositories then use time machine to backup.
* Use spaces.

提示:
* 使用 Windows Steady State 保持操作系统一致
* 使用 svn+ssh 连接到 mac 对于小型存储库,然后使用 time machine 备份。
* 使用空格。

采纳答案by Boaz

@Andrew - I'm exactly in your situation. I use a MBP while my company work is purely Microsoft based: i.e., .NET, COM etc. While nothing can beat running Vista natively in Boot Camp (I've never seen Vista run so fast), the niceties of having your Mac OS be the "main" OS, for internet, mail etc. has gotten me to the following configuration. Works like a charm:

@Andrew - 我正好在你的情况下。我使用 MBP,而我的公司工作完全基于 Microsoft:即 .NET、COM 等。虽然没有什么比在 Boot Camp 中本地运行 Vista 更胜一筹(我从未见过 Vista 运行得如此之快),但拥有 Mac OS 的好处成为“主要”操作系统,用于互联网、邮件等,让我得到了以下配置。奇迹般有效:

Hardware

硬件

  • Load up your MBP with the max possible - 4GB. It's really worth every $.
  • Upgrade your hard drive (if not already) to 7200RPM. Major performance boost here.
  • 尽可能加载您的 MBP - 4GB。这真的值得每一美元。
  • 将您的硬盘驱动器(如果还没有)升级到 7200RPM。这里的主要性能提升。

Software

软件

  • Parallels Desktop for Macfor virtualization. You can either have multiple VM, or use a boot camp partition. The latter is supposed to be faster, but I haven't really measured it (I use it for having the option to boot natively if I really need speed). The former allows you to have multiple OS. I gave my VM 1GB memory. I can do more if you want it more snappy.
  • Micorsoft Visual Studio 2005/8 for .NET and C++. I have yet to see any IDE for .NET which beats this one. The intellisenseis really amazing.
  • Code Gear (yes we have some Delphi)
  • 用于虚拟化的Parallels Desktop for Mac。您可以拥有多个 VM,也可以使用 Boot Camp 分区。后者应该更快,但我还没有真正测量过它(如果我真的需要速度,我使用它来选择本地启动)。前者允许您拥有多个操作系统。我给了我的 VM 1GB 内存。如果你想要它更活泼,我可以做更多。
  • 适用于 .NET 和 C++ 的 Micorsoft Visual Studio 2005/8。我还没有看到任何 .NET IDE 胜过这个。该智能感知更是惊人。
  • Code Gear(是的,我们有一些 Delphi)

For non development occasional need I also keep Microsoft Office 2007 installed. They do have MAC ports, but those don't always cut it.

对于非开发偶尔需要,我还安装了 Microsoft Office 2007。他们确实有 MAC 端口,但那些并不总是切断它。

回答by t3rse

One more thing, there is a Deep Fried Bytes Podcastthat is entirely about .NET development on Mac - you may find some nuggets in there too.

还有一件事,有一个Deep Fried Bytes Podcast,它完全是关于 Mac 上的 .NET 开发——你也可以在那里找到一些金块。

回答by Josh Hinman

I develop in ASP.Net on my mac almost daily, and I have to question why you aren't interested in Boot Camp. Yeah, VMWare is nice, but for my money nothing beats the performance of running Windows by itself on the Mac.

我几乎每天都在我的 Mac 上使用 ASP.Net 进行开发,我不得不质疑为什么您对 Boot Camp 不感兴趣。是的,VMWare 很好,但就我而言,没有什么比在 Mac 上单独运行 Windows 的性能更好的了。

回答by TALlama

I'm in the same boat; VMware on a MBP, doing .NET development (and a little Mono, but that's a different beast). I would recommend updating to the Fusion 2.0 betas if you haven't yet; they're faster and offer some great new features (multiple snapshots! application linking!) and, in my experience, are just as stable as the 1.x releases.

我在同一条船上;VMware 在 MBP 上,进行 .NET 开发(还有一点 Mono,但那是一个不同的野兽)。如果您还没有更新到 Fusion 2.0 测试版,我建议您更新;它们速度更快,并提供了一些很棒的新功能(多个快照!应用程序链接!),并且根据我的经验,与 1.x 版本一样稳定。

回答by xanadont

  • The extra RAM is great for your OS X environment, but my experience has shown you shouldn't exceed VMWare's recommended RAM settings of 1G.
  • I was unsuccessful at getting a good experience running my VM(s) from an external drive. And it's a firewire 800. Keep your dev image pruned to as little space as possible and run directly from your internal drive.
  • If you're sticking with XP (good choice BTW), you might want to give VirtualBox a try. It's VERY zippy. However, it chokes on Vista.
  • If you have a thought about trying Parallels ... DON'T!!! It worked well enough for a while but eventually became very unstable, crashing often when host files were accessed and freezing 2 out of 3 times during startup. Also, their implementation of networking is convoluted and difficult to setup if, say, you wanted to browse an Apache site on your host from your guest.
  • If you need to resize your image, there's a good tutorial for Parallels using GParted and Partition Magic. I'm sure it would be simple to adapt it to VMWare.
  • Your use of SVN is almost exactly what I do (repo is on host, backed up with Time Machine). However, you could speed it up and remove the bloat of a server if you go with simply a file-based repository.
  • 额外的 RAM 非常适合您的 OS X 环境,但我的经验表明您不应超过 VMWare 推荐的 1G RAM 设置。
  • 我未能获得从外部驱动器运行我的 VM 的良好体验。它是一个火线 800。将您的开发映像修剪到尽可能小的空间,并直接从您的内部驱动器运行。
  • 如果您坚持使用 XP(顺便说一句,不错的选择),您可能想尝试一下 VirtualBox。它非常活泼。但是,它在 Vista 上会窒息。
  • 如果您有尝试使用 Parallels 的想法...不要!!!它在一段时间内运行良好,但最终变得非常不稳定,在访问主机文件时经常崩溃,并且在启动期间冻结了 3 次。此外,如果您想从您的来宾浏览主机上的 Apache 站点,则它们的网络实现是复杂且难以设置的。
  • 如果您需要调整图像大小,可以使用有关使用 GParted 和 Partition Magic 的 Parallels 的很好的教程。我相信让它适应 VMWare 会很简单。
  • 您对 SVN 的使用与我所做的几乎一模一样(repo 在主机上,由 Time Machine 备份)。但是,如果您只使用基于文件的存储库,则可以加快速度并消除服务器的膨胀。

回答by robsoft

Just extending this out slightly from the original question, there are some of us doing Delphi Windows development work on virtual machines, too.

只是从最初的问题稍微扩展一下,我们中的一些人也在虚拟机上进行 Delphi Windows 开发工作。

I've got a MacBook Pro (1st gen) with a couple of gigs of ram, and a recent iMac (with 4 gigs of ram). I've had more luck than xanadont with external drives, running a couple of different brands on Firewire 400 and finding them to be fine with 16-20Gb VMs. If I'm going to be in one place for a few days (either in the office on the iMac or on the road with the MBP) then I'll copy the VM to the local drive but as a rule it's worked fine for about 2 years now.

我有一台配备几台内存的 MacBook Pro(第一代)和一台最近的 iMac(配备 4 台内存)。我比使用外部驱动器的 xanadont 更幸运,在 Firewire 400 上运行了几个不同的品牌,并发现它们在 16-20Gb 虚拟机上没问题。如果我要在一个地方呆几天(在 iMac 上的办公室或在路上带着 MBP),那么我会将 VM 复制到本地驱动器,但通常它可以正常工作约现在2年了。

I started with Parallels, but there came a point when they started releasing versions that hadn't been regression tested, and sometimes basic stuff would suddenly be broken in the current release. Simple fix, stop downloading the new version and stay 3-6 months behind everyone else. Then I needed to give a VM to a colleague and had to go through a few hoops getting it out of Parallels and into VMware. At that point I tried the Fusion beta, had first-hand experience of moving a VM between Mac and Windows (with no real fuss at all) and that persuaded me to switch to Fusion. I have to say, Fusion is an excellent, stable, reliable tool.

我从 Parallels 开始,但是当他们开始发布未经回归测试的版本时,有时基本的东西会在当前版本中突然被破坏。简单修复,停止下载新版本并落后于其他人 3-6 个月。然后我需要给一位同事一个虚拟机,并且不得不通过几个环节将它从 Parallels 中取出并进入 VMware。那时我尝试了 Fusion 测试版,获得了在 Mac 和 Windows 之间移动 VM 的第一手经验(完全没有大惊小怪),这说服我改用 Fusion。不得不说,Fusion 是一款优秀、稳定、可靠的工具。

I run WInXP Pro SP 3, Delphi 7, Delphi 2007, SQL Express and various development tools on my VMs (I tend to have a VM for each of my clients).

我在我的虚拟机上运行 WInXP Pro SP 3、Delphi 7、Delphi 2007、SQL Express 和各种开发工具(我倾向于为我的每个客户端都有一个虚拟机)。

And I agree with xanadont about the 1Gig ram thing - mine tend to have a gig and no more - I didn't see any real change in behaviour/performance with >1Gb in the vm, so it's better off given to the host operating system rather than the virtual one.

我同意 xanadont 关于 1Gig ram 的看法 - 我的往往有一个演出,没有更多 - 我没有看到 vm 中>1Gb 的行为/性能有任何真正的变化,所以最好给主机操作系统而不是虚拟的。

回答by Sixto Saez

This is not purely .NET related but it is in the vein of the using Spaces item in the question.

这不是纯粹的 .NET 相关,但它与问题中的 using Spaces 项目有关。

Trackpad tips for a MacBook running Leopard (may not be supported in earlier OS X versions):

运行 Leopard 的 MacBook 的触控板提示(较早的 OS X 版本可能不支持):

  • Set System Preferences, Keyboard & Mouse, Trackpad to use Two Finger Secondary Click. This allows you to use two finger taps instead of the Control + Click combo for the Secondary Click (better know as the context menu to us .NET developers).

  • Set System Preferences, Keyboard & Mouse, Trackpad to use Two Finger Screen Zoom for magnifying an area in the screen by holding the Control key and scrolling up or down. This is useful for quickly magnifying small fonts or image detail in any Mac application and in Windows running under VMware Fusion. You can pick either the Control, Option or Command keys for zooming by clicking the Options button along with other settings.

  • 设置系统偏好设置、键盘和鼠标、触控板以使用两指辅助点击。这允许您使用两个手指点击而不是 Control + Click 组合来进行二次单击(对于我们 .NET 开发人员来说,最好将其称为上下文菜单)。

  • 设置系统偏好设置、键盘和鼠标、触控板以使用两指屏幕缩放通过按住 Control 键并向上或向下滚动来放大屏幕中的区域。这对于在任何 Mac 应用程序和在 VMware Fusion 下运行的 Windows 中快速放大小字体或图像细节非常有用。您可以通过单击选项按钮和其他设置来选择用于缩放的 Control、Option 或 Command 键。

回答by Brian Warshaw

Oded, it depends on what type of .NET development one is trying to do, and for what platform. If you're targeting Windows and building something other than console apps, you're best off not using Mono, as Mono projects are not necessarily drop-in-to-Windows-and-go solutions.

Oded,这取决于人们尝试进行哪种类型的 .NET 开发,以及针对什么平台。如果您的目标是 Windows 并构建非控制台应用程序,那么最好不要使用 Mono,因为 Mono 项目不一定是 Windows-and-go 解决方案。

回答by Oded

I believe project monohas mac support.

我相信单声道项目有 mac 支持。

This assumes you want to develop directly on the mac and that you are happy to forgo some of the MS specific features and tools (so no C#3.0, libraries like WPF and Visual Studio).

这假设您想直接在 mac 上开发,并且您乐于放弃某些 MS 特定功能和工具(因此没有 C#3.0、WPF 和 Visual Studio 等库)。

Of course, using paralles/vmware/virtualbox or any other virtual machine with a windows guest as you describe will also work fine.

当然,如您所描述的那样,使用 paralles/vmware/virtualbox 或任何其他带有 Windows 来宾的虚拟机也可以正常工作。

回答by Sara Chipps

I use a Mac Book Pro as well but I run Vista. I set aside a little space so I could also run Leopard and just use Boot Camp. You can use Boot Camp to just boot from windows so you never have to deal with Leopard unless you want to.

我也使用 Mac Book Pro,但我运行的是 Vista。我留出了一点空间,这样我也可以运行 Leopard 并只使用 Boot Camp。您可以使用 Boot Camp 从 Windows 启动,这样您就不必处理 Leopard,除非您愿意。

I would highly reccomend it because Apple makes great hardware while Microsoft makes great tools (and also great OSs, I love Vista)

我强烈推荐它,因为 Apple 制造出色的硬件,而 Microsoft 制造出色的工具(以及出色的操作系统,我喜欢 Vista)

go ahead and downmod me for being a fangirl, but I've found what works for me.

继续并贬低我作为一个狂热的女孩,但我已经找到了对我有用的东西。