From d0a4f4b76b5fa2e4dd113b05d2860a5905e2734e Mon Sep 17 00:00:00 2001 From: jackfiled Date: Tue, 25 Mar 2025 15:17:34 +0800 Subject: [PATCH] blog: update msbuild-generate-files --- .../source/posts/msbuild-generate-files.md | 30 +++++++++++++++++++ .../image-20250325150841442.webp | 3 ++ 2 files changed, 33 insertions(+) create mode 100644 YaeBlog/source/posts/msbuild-generate-files/image-20250325150841442.webp diff --git a/YaeBlog/source/posts/msbuild-generate-files.md b/YaeBlog/source/posts/msbuild-generate-files.md index a823395..8fcd709 100644 --- a/YaeBlog/source/posts/msbuild-generate-files.md +++ b/YaeBlog/source/posts/msbuild-generate-files.md @@ -6,6 +6,7 @@ tags: - dotnet --- + 如何使用`MSBuild`将构建过程中生成文件复制到生成目录中? @@ -115,3 +116,32 @@ tags: 经过测试,这套生成逻辑在`blazor`类库环境下也可以正常运行,类库的文件会被正确地生成到`wwwroot/_content//`文件夹下面。 +### 新的问题 + +在上述代码合并之后,我在后续开发过程中却遇到的了新的问题:在开发环境下项目运行的目录是源代码目录,而此时的`wwwroot`目录下面没有`tailwind.g.css`文件,此时网站再次丢失了样式,而如果使用`pnpm tailwindcss -i wwroot/tailwind.css -o wwwroot/tailwind.g.css`生成文件的话,却会遇到构建错误: + +![image-20250325150841442](./msbuild-generate-files/image-20250325150841442.webp) + +这是因为`.NET SDK`也会尝试将已经存在的`wwwroot/tailwind.g.css`复制到输出文件中,这就会造成冲突。 + +因此为了让开发环境和测试环境可以共存,我让`TailwindGenerate`目标只在`dotnet publish`运行,而在开发环境中使用`pnpm tailwindcss`手动生成`CSS`文件。 + +```xml + + + + + + + + + + + + + + + + +``` + diff --git a/YaeBlog/source/posts/msbuild-generate-files/image-20250325150841442.webp b/YaeBlog/source/posts/msbuild-generate-files/image-20250325150841442.webp new file mode 100644 index 0000000..d76a83c --- /dev/null +++ b/YaeBlog/source/posts/msbuild-generate-files/image-20250325150841442.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f5ad19fed6a5070df683cd33dff436198ca19e7a0db23eb1348ddee1df7c6d7d +size 21830