我的 .net core 应用程序变得令人惊叹,所有兄弟都想使用它。我需要为他们提供一种让项目运行的安全方法,以及一种在未来添加发布任务的策略。
现在,由于我在这个问题和这个问题中收到的帮助,我使用以下命令运行我的应用程序。
dotnet watch run --environment "Development"
Run Code Online (Sandbox Code Playgroud)
如果我能让我的开发人员使用更简单的东西,也许是自定义任务 ala npm 脚本,我会很高兴:
dotnet run dev
Run Code Online (Sandbox Code Playgroud)
我知道有基础设施可以通过 .csproj 文件中的 msbuild 支持此类事情,但文档对我来说还没有解决。
我是 Visual Studio Code 新手。我想在我的 csproj 中定义输出目录。我不知道在 Visual Studio Code 中的何处更改目标文件夹以查找生成的 dll 文件。
当尝试构建面向 net47 而不是 .netcore 或 .net std 的 Microsoft.NET.Sdk 样式项目时。将dotnet build给出有关缺少目标包的错误。msbuild 可以代替,但我更喜欢使用dotnet build. 有办法吗。
/usr/local/share/dotnet/sdk/2.1.200/Microsoft.Common.CurrentVersion.targets
(1179,5): error MSB3644: The reference assemblies for framework
".NETFramework,Version=v4.7" were not found. To resolve this, install the
SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or
Targeting Pack installed. Note that assemblies will be resolved from the
Global Assembly Cache (GAC) and will be used …Run Code Online (Sandbox Code Playgroud) 我有一个 csproj 文件,其中包含一些目标运行时,我希望有一个可以运行的单一命令,该命令可以将它们全部构建并将它们放在指定的目录中。像这样的东西:
dotnet publish -c release -o ../../some-dist-folder
Run Code Online (Sandbox Code Playgroud)
如果我运行这个命令,我会得到some-dist-folder很多好东西,但我不确定它是只输出单个运行时还是所有运行时,因为文件夹包含:
|- *.dll
|- Refs
|- *.dll
|- Runtimes
|- Lots of folders
Run Code Online (Sandbox Code Playgroud)
所以没有 exe(并不感到惊讶,因为那只是 Windows 的东西)并且运行时似乎包含大量与各种 linux/mac/windows 运行时等相关的文件夹。
但是,如果我要运行:
dotnet publish -c release -r win-x64 -o ../../some-dist-folder
Run Code Online (Sandbox Code Playgroud)
我得到一些 apphost.exe和其他一些文件并且 runtimes 文件夹不见了,所以我想知道我试图一次构建所有东西的前一种方法是否实际上不起作用,我需要为每个平台明确发布,或者我是否需要从输出中手动挑选出我关心的位。
理想情况下,我希望运行类似上面的命令并获得一个输出文件夹,例如:
|- some-dist-folder
|- win-x64
|- osx-some-version
|- some-linux-distro-version
|- other-runtimes-version
Run Code Online (Sandbox Code Playgroud)
那么我可以在单个命令中接近这个,还是明确地手动运行每个发布更安全?
我今天安装了 Visual Studio 2019 GA Released 版本。
我通过命令行安装了这个模板https://github.com/Dotnet-Boxed/Templatesdotnet new
然后我可以使用dotnet new来从命令行创建一个项目。
但是,已安装的模板不会显示在 Visual Studio 2019 的此窗口中。
放置从 CLI 安装新模板的链接但不在 UI 中列出新安装的模板有什么意义?
这是错误还是实际上缺少功能?
当我想将我的库打包为 NuGet 包时,出现以下错误
指定的 DateTimeOffset 无法转换为 Zip 文件时间戳
我使用以下命令来打包我的项目:
dotnet msbuild /t:pack /p:Configuration=Release /p:SourceLinkCreate=true
Run Code Online (Sandbox Code Playgroud) 我正在尝试将 Github Actions 设置为: -build .net Core 应用程序 -测试应用程序(单元测试) -发布版本(dotnet 发布) -部署到 ftp 服务器
我在最后一步遇到一些问题。我正在使用此操作部署到 ftp:https ://github.com/SamKirkland/FTP-Deploy-Action
它始终部署整个存储库,而不仅仅是发布文件。
我的工作流程:
name: BuildAndTest
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
- name: Install dependencies
run: dotnet restore
- name: Build with dotnet
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
- name: …Run Code Online (Sandbox Code Playgroud) 我已经尝试了官方文档中示例命令的所有可以想象的组合,但这些都使用 nuget.exe。
以下nuget 问题指出使用 dotnet cli 发布到官方 nuget.org v3 端点https://api.nuget.org/v3/index.json是有效的。
当发布到 MyGet v3 端点时
dotnet nuget push <package-name>.nupkg --api-key <write-api-key> --source https://www.myget.org/F/<some-site>/api/v3/index.json
Run Code Online (Sandbox Code Playgroud)
文件.nupkg已发布,但.snupkg文件未发布。
仅.snupkg将文件发布到 MyGet v3 端点时
dotnet nuget push <package-name>.snupkg --api-key <write-api-key> --source https://www.myget.org/F/<some-site>/api/v3/index.json
Run Code Online (Sandbox Code Playgroud)
结果是:
error: Unable to load the service index for source https://www.myget.org/F/<some-site>/api/v3/index.json.
error: Response status code does not indicate success: 401 (Unauthorized).
Run Code Online (Sandbox Code Playgroud)
还尝试过:
dotnet nuget push <package-name>.snupkg --api-key <write-api-key> --source https://www.myget.org/F/<some-site>/api/v3/index.json --no-service-endpoint
Run Code Online (Sandbox Code Playgroud)
..结果相同
通过 WebUI …
尝试发布一个控制台应用程序以在 Linux 计算机上运行,我像这样发布
dotnet publish -c Release -r linux-x64
Run Code Online (Sandbox Code Playgroud)
我尝试运行该应用程序并收到此错误
An assembly specified in the application dependencies manifest (XXX.deps.json) was not found:
package: 'runtime.linux-x64.Microsoft.NETCore.App', version: '2.2.0'
path: 'runtimes/linux-x64/native/createdump'
Run Code Online (Sandbox Code Playgroud)
我尝试使用发布配置文件发布到新的输出目录。
dotnet publish -p:PublishProfile=Properties\PublishProfiles\FolderProfile.pubxml -o:Release/OutP5
Run Code Online (Sandbox Code Playgroud)
现在我的输出目录包含一个“runtime”目录,但其中没有 linux-x64 目录,我尝试在 pubxml 中添加 RuntimeIdentifier 元素,没有更改,我尝试使用发布配置文件,但也指定了运行时:
dotnet publish -p:PublishProfile=Properties\PublishProfiles\FolderProfile.pubxml -o:Release/OutP6 -r linux-x64
Run Code Online (Sandbox Code Playgroud)
现在我的新输出目录没有运行时目录。
我正在输掉这场打地鼠游戏,但我不知道为什么。我缺少什么?
我有 .sln 文件,其中包含不同文件夹中的一些项目,最初在根文件夹中我有src和Tests文件夹和 sln 文件。其结构如下图所示:
当我运行时,dotnet build它会构建所有项目。另一种方法是传递<PROJECT | SOLUTION>文件以构建更具体的东西。我需要根据通配符仅构建特定项目或从构建中排除某些项目。
当我尝试通过 **/src/*.csproj或!Tests/**它不过滤项目但给出来自 MSBuild 的错误时:
Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1009: Project file does not exist.
Switch: **/src/*.csproj
Run Code Online (Sandbox Code Playgroud)
有没有办法根据通配符模式构建项目?