<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mac &#8211; Bubblog</title>
	<atom:link href="https://blog.yangyuanping.com/tag/mac/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.yangyuanping.com</link>
	<description>nullable reference types</description>
	<lastBuildDate>Tue, 23 Dec 2025 14:19:57 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://blog.yangyuanping.com/wp-content/uploads/2025/11/cropped-patrick_log_logo_251121-2-32x32.png</url>
	<title>Mac &#8211; Bubblog</title>
	<link>https://blog.yangyuanping.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Mac 中使用 VSCode 开发 Framework 项目指南</title>
		<link>https://blog.yangyuanping.com/mac-%e4%b8%ad%e4%bd%bf%e7%94%a8-vscode-%e5%bc%80%e5%8f%91-framework-%e9%a1%b9%e7%9b%ae%e6%8c%87%e5%8d%97/</link>
		
		<dc:creator><![CDATA[peny911]]></dc:creator>
		<pubDate>Tue, 23 Dec 2025 14:19:57 +0000</pubDate>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[VSCode]]></category>
		<guid isPermaLink="false">https://blog.yangyuanping.com/?p=1072</guid>

					<description><![CDATA[前置要求 对于 .NET Framework 4.5.2 项目，在 macOS 上需要使用 Mono 来运行。 [&#8230;]]]></description>
										<content:encoded><![CDATA[<h2>前置要求</h2>
<p>对于 .NET Framework 4.5.2 项目，在 macOS 上需要使用 Mono 来运行。</p>
<h2>第一步：安装必需工具</h2>
<h3>1. 安装 Mono</h3>
<pre><code class="language-bash">brew install mono</code></pre>
<p>验证安装：</p>
<pre><code class="language-bash">mono --version</code></pre>
<h3>2. 安装 NuGet</h3>
<pre><code class="language-bash">brew install nuget</code></pre>
<h3>3. 安装 MSBuild (包含在 Mono 中)</h3>
<p>验证安装：</p>
<pre><code class="language-bash">msbuild -version</code></pre>
<h3>4. 安装 XSP (Mono 的 Web 服务器)</h3>
<pre><code class="language-bash">brew install xsp</code></pre>
<h2>第二步：安装 VSCode 扩展</h2>
<p>在 VSCode 中安装以下扩展（已在 &lt;code&gt;.vscode/extensions.json&lt;/code&gt; 中推荐）：</p>
<ol>
<li><strong>C# Dev Kit</strong> &#8211; 微软官方 C# 支持</li>
<li><strong>C#</strong> &#8211; OmniSharp 语言服务</li>
<li><strong>.NET Test Explorer</strong> &#8211; 测试资源管理器</li>
</ol>
<p>重启 VSCode 以激活扩展。</p>
<h2>第三步：构建项目</h2>
<h3>方法 1：使用 VSCode 任务（推荐）</h3>
<ol>
<li>按 &lt;code&gt;Cmd+Shift+P&lt;/code&gt; 打开命令面板</li>
<li>选择 &lt;code&gt;Tasks: Run Task&lt;/code&gt;</li>
<li>选择 &lt;code&gt;构建解决方案 (Debug)&lt;/code&gt;</li>
</ol>
<h3>方法 2：使用终端命令</h3>
<pre><code class="language-bash"># 恢复 NuGet 包
nuget restore &lt;Solution-Name&gt;.sln

# 构建项目
msbuild &lt;Solution-Name&gt;.sln /p:Configuration=Debug</code></pre>
<h2>第四步：运行和调试</h2>
<h3>运行 WebAPI 项目</h3>
<h4>方法 1：使用 XSP（Mono Web 服务器）</h4>
<pre><code class="language-bash"># 在终端中运行
xsp4 --port=&lt;PORT&gt; --path=&lt;ProjectName&gt;</code></pre>
<p>然后访问：<a href="http://localhost:23985/api/message">http://localhost:23985/api/message</a></p>
<h4>方法 2：使用 VSCode 任务</h4>
<ol>
<li>按 &lt;code&gt;Cmd+Shift+P&lt;/code&gt;</li>
<li>选择 &lt;code&gt;Tasks: Run Task&lt;/code&gt;</li>
<li>选择 &lt;code&gt;运行 WebAPI (XSP)&lt;/code&gt;</li>
</ol>
<h3>调试代码</h3>
<ol>
<li>在代码中设置断点（点击行号左侧）</li>
<li>按 &lt;code&gt;F5&lt;/code&gt; 或点击调试面板的&quot;开始调试&quot;</li>
<li>选择配置：&lt;code&gt;调试 WebAPI (Mono)&lt;/code&gt;</li>
</ol>
<h3>运行单元测试</h3>
<h4>使用 VSCode 任务：</h4>
<ol>
<li>按 &lt;code&gt;Cmd+Shift+P&lt;/code&gt;</li>
<li>选择 &lt;code&gt;Tasks: Run Task&lt;/code&gt;</li>
<li>选择 &lt;code&gt;运行单元测试&lt;/code&gt;</li>
</ol>
<h4>使用命令行：</h4>
<pre><code class="language-bash"># 首先需要安装 NUnit Console Runner（如果还没有）
nuget install NUnit.ConsoleRunner -Version 3.15.0 -OutputDirectory packages

# 运行测试
mono packages/NUnit.ConsoleRunner.3.15.0/tools/nunit3-console.exe \
  &lt;TestProjectName&gt;/bin/Debug/&lt;TestProjectName&gt;.dll</code></pre>
<h2>常用 VSCode 快捷键</h2>
<ul>
<li>&lt;code&gt;Cmd+Shift+B&lt;/code&gt; &#8211; 运行默认构建任务</li>
<li>&lt;code&gt;F5&lt;/code&gt; &#8211; 开始调试</li>
<li>&lt;code&gt;Shift+F5&lt;/code&gt; &#8211; 停止调试</li>
<li>&lt;code&gt;F9&lt;/code&gt; &#8211; 切换断点</li>
<li>&lt;code&gt;F10&lt;/code&gt; &#8211; 单步跳过</li>
<li>&lt;code&gt;F11&lt;/code&gt; &#8211; 单步进入</li>
<li>&lt;code&gt;Cmd+K Cmd+D&lt;/code&gt; &#8211; 格式化文档</li>
</ul>
<h2>常见问题</h2>
<h3>1. Mono 找不到程序集</h3>
<p>确保已运行 &lt;code&gt;nuget restore&lt;/code&gt; 来恢复所有依赖包。</p>
<h3>2. MSBuild 失败</h3>
<p>检查 Mono 版本是否支持 .NET Framework 4.5.2：</p>
<pre><code class="language-bash">mono --version</code></pre>
<p>需要 Mono 5.0 或更高版本。</p>
<h3>3. XSP 无法启动</h3>
<p>确保端口 23985 未被占用：</p>
<pre><code class="language-bash">lsof -i :23985</code></pre>
<h3>4. OmniSharp 无法加载项目</h3>
<p>在 VSCode 设置中确保：</p>
<ul>
<li>&lt;code&gt;omnisharp.useModernNet&lt;/code&gt; 设置为 &lt;code&gt;false&lt;/code&gt;</li>
<li>&lt;code&gt;omnisharp.monoPath&lt;/code&gt; 指向正确的 Mono 安装路径</li>
</ul>
<h2>已知限制</h2>
<ol>
<li><strong>调试功能受限</strong>：Mono 的调试体验不如 Windows 上的 Visual Studio</li>
<li><strong>性能差异</strong>：Mono 运行性能可能低于 Windows .NET Framework</li>
<li><strong>某些 API 不可用</strong>：部分 Windows 特定的 API 在 Mono 上不支持</li>
</ol>
<h2>建议</h2>
<p>对于生产环境部署，建议：</p>
<ol>
<li>在 Windows Server 上使用 IIS 托管</li>
<li>或考虑将项目迁移到 .NET 6/8 以获得跨平台支持</li>
</ol>
<h2>迁移到现代 .NET 的好处</h2>
<p>如果你计划长期维护此项目，可以考虑迁移到 .NET 8：</p>
<ul>
<li>原生跨平台支持（无需 Mono）</li>
<li>更好的性能</li>
<li>现代化的工具链</li>
<li>长期支持（LTS）</li>
</ul>
<p>迁移步骤请参考：<a href="https://docs.microsoft.com/zh-cn/aspnet/core/migration/">https://docs.microsoft.com/zh-cn/aspnet/core/migration/</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Mac 中刷新 DNS</title>
		<link>https://blog.yangyuanping.com/mac-%e4%b8%ad%e5%88%b7%e6%96%b0-dns/</link>
		
		<dc:creator><![CDATA[peny911]]></dc:creator>
		<pubDate>Wed, 26 Nov 2025 15:40:53 +0000</pubDate>
				<category><![CDATA[Linux Nibbles]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Mac]]></category>
		<guid isPermaLink="false">https://blog.yangyuanping.com/?p=1039</guid>

					<description><![CDATA[在 Mac（macOS） 中刷新 DNS 缓存没有像 Windows 那样统一的 &#60;code&#62;ip [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>在 <strong>Mac（macOS）</strong> 中刷新 DNS 缓存没有像 Windows 那样统一的 &lt;code&gt;ipconfig /flushdns&lt;/code&gt;，而是<strong>按系统版本使用不同的 &lt;code&gt;dscacheutil&lt;/code&gt; + &lt;code&gt;killall mDNSResponder&lt;/code&gt; 组合命令</strong>。</p>
<hr />
<h2><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 一行通用万能命令（推荐直接用这个）</h2>
<p>在 <strong>终端（Terminal）</strong> 中执行：</p>
<pre><code class="language-bash">sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder</code></pre>
<p>输入你的 <strong>系统登录密码</strong>（不会显示），回车即可完成刷新。</p>
<blockquote>
<p>这个命令适用于：</p>
</blockquote>
<ul>
<li>macOS Ventura (13)</li>
<li>macOS Sonoma (14)</li>
<li>macOS Sequoia (15)</li>
<li>Monterey (12)</li>
<li>Big Sur (11)</li>
<li>Catalina (10.15)</li>
<li>Mojave (10.14)</li>
</ul>
<hr />
<h2><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 各系统版本对应命令（备用参考）</h2>
<table>
<thead>
<tr>
<th>macOS 版本</th>
<th>刷新 DNS 命令</th>
</tr>
</thead>
<tbody>
<tr>
<td>10.10.4 及以后</td>
<td>&lt;code&gt;sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder&lt;/code&gt;</td>
</tr>
<tr>
<td>10.10 – 10.10.3</td>
<td>&lt;code&gt;sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches&lt;/code&gt;</td>
</tr>
<tr>
<td>10.7 – 10.9</td>
<td>&lt;code&gt;sudo killall -HUP mDNSResponder&lt;/code&gt;</td>
</tr>
<tr>
<td>10.5 – 10.6</td>
<td>&lt;code&gt;sudo dscacheutil -flushcache&lt;/code&gt;</td>
</tr>
</tbody>
</table>
<hr />
<h2><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 如何判断是否刷新成功？</h2>
<p>macOS 刷新 DNS <strong>默认是没有任何成功提示的</strong>，这是正常现象 <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
如果你想确认是否真的生效，可以：</p>
<pre><code class="language-bash">ping your-domain.com</code></pre>
<p>或：</p>
<pre><code class="language-bash">nslookup your-domain.com</code></pre>
<hr />
<h2><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 适合你的使用场景（比如你刚刚在折腾这些）</h2>
<p>你最近使用的场景包括：</p>
<ul>
<li><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 花生壳 / 动态域名解析</li>
<li><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 公网 IP + 远程桌面</li>
<li><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 路由器 DDNS 解析切换</li>
<li><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 域名刚刚改解析但访问不生效</li>
</ul>
<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>这时候刷新 DNS 是“必须操作”之一，否则很容易一直命中旧 IP</strong>。</p>
<hr />
<h2><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 进阶：同时刷新 WiFi/网络缓存（更彻底）</h2>
<p>如果你遇到的是那种 <strong>“DNS 已改，但 Mac 仍然连不上”</strong> 的顽固情况，可以：</p>
<pre><code class="language-bash">sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
sudo ifconfig en0 down
sudo ifconfig en0 up</code></pre>
<p>（&lt;code&gt;en0&lt;/code&gt; 是常见的 WiFi 网卡）</p>
<hr />
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Mac OS X uninstall script for packaged install of node.js</title>
		<link>https://blog.yangyuanping.com/mac-os-x-uninstall-script-for-packaged-install-of-node-js/</link>
		
		<dc:creator><![CDATA[peny911]]></dc:creator>
		<pubDate>Mon, 24 Nov 2025 18:49:24 +0000</pubDate>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Node.js]]></category>
		<guid isPermaLink="false">https://blog.yangyuanping.com/?p=1033</guid>

					<description><![CDATA[To run this, you can try: curl -ksO https://gist.github [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>To run this, you can try:</p>
<pre><code class="language-bash">curl -ksO https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh
chmod +x ./uninstall-node.sh
./uninstall-node.sh
rm uninstall-node.sh</code></pre>
<p><a href="https://gist.github.com/nicerobot/2697848#file-uninstall-node-sh" title="uninstall-node.sh">uninstall-node.sh</a></p>
<pre><code class="language-bash">#!/bin/sh
(( ${#} &gt; 0 )) || {
  echo 'DISCLAIMER: USE THIS SCRIPT AT YOUR OWN RISK!'
  echo 'THE AUTHOR TAKES NO RESPONSIBILITY FOR THE RESULTS OF THIS SCRIPT.'
  echo "Disclaimer aside, this worked for the author, for what that's worth."
  echo 'Press Control-C to quit now.'
  read
  echo 'Re-running the script with sudo.'
  echo 'You may be prompted for a password.'
  sudo ${0} sudo
  exit $?
}
# This will need to be executed as an Admin (maybe just use sudo).

for bom in org.nodejs.node.pkg.bom org.nodejs.pkg.bom; do

  receipt=/var/db/receipts/${bom}
  [ -e ${receipt} ] &amp;&amp; {
    # Loop through all the files in the bom.
    lsbom -f -l -s -pf ${receipt} \
    | while read i; do
      # Remove each file listed in the bom.
      rm -v /usr/local/${i#/usr/local/}
    done
  }

done

# Remove directories related to node.js.
rm -vrf /usr/local/lib/node \
  /usr/local/lib/node_modules \
  /var/db/receipts/org.nodejs.*

exit 0</code></pre>
<blockquote>
<p><a href="https://gist.github.com/nicerobot/2697848">https://gist.github.com/nicerobot/2697848</a></p>
</blockquote>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
