我有一个项目引用了一些 nuget 包。
在输出文件夹(bin\Debug或bin\Release)中,所有引用的库都位于可执行文件旁边。
如何指定库的输出文件夹?
我想要所有 nuget 库bin\Release\Libs并在bin\Release.
我的 csproj 文件中有一个构建后目标,如下所示。
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="dotnet publish '..\..\src\httpapi\httpapi.csproj' -o $(OutputPath)\service"/>
</Target>
Run Code Online (Sandbox Code Playgroud)
在我的本地计算机上运行没有任何问题,但在 sonarqube 服务器上构建时失败并出现以下错误。
MSBUILD : error MSB1009: Project file does not exist.
- Switch: '..\..\src\httpapi\httpapi.csproj'
Run Code Online (Sandbox Code Playgroud)
知道为什么会发生这种情况吗?有没有其他方法可以在我的构建后目标中提及目标项目的路径?
在Visual Studio中我很确定有一种方法可以在多个项目中"别名"一个文件.换句话说,实际文件只存在于文件系统中的一个位置,但在两个或多个.csproj文件中有多个引用.如果没有打开.csproj并创建这样的别名,我将如何在Visual Studio中执行此操作?
我正在使用csproj文件,我正在尝试编写一个cmdlet来提取项目文件引用的所有文件.这将包括所有Compile,EmbeddedResource,Resource,Content和None元素(更重要的是,它们的@Include值),但我特别想要将引用元素排除在它们引用的dll之外,这些对我来说并不重要.
我没有太多的经验,但我认为我想要的xpath表达式看起来像这样
$projectFile | Select-Xml -namespace @{msb="http://schemas.microsoft.com/developer/msbuild/2003"} -xpath "//msb:ItemGroup/*[not(self::node() = msb:Reference) and @Include]"
Run Code Online (Sandbox Code Playgroud)
但是,只要我尝试引入self :: node(),我的表达式就不会返回任何节点.我不是100%确定self :: node()是正确的方法.知道我会改变什么以使其返回,概念上,"所有包含属性的属性值都不是作为ItemGroup元素的子元素的Reference元素吗?"
我想添加一个带有条件的属性到csproj文件.
条件是:如果网络位置可用,我的属性应具有该值,否则为另一个位置.
任何提示?
谢谢,Horea
我们遇到了一些构建错误,我们需要手动修复引用.我想以编程方式检查项目引用是否已定义而不是dll引用:因此,请查看解决方案中的所有引用以及每个项目,检查引用是否已正确定义.这样就可以正确配置相关的依赖项.
有人知道现有的解决方案吗?我想要一个在门控签到之前运行的验证工具.
我在构建时使用MSBuild动态生成资源文件,但为了能够在运行时从该资源文件中读取,我需要它作为嵌入式资源.
我已经到处查看如何在.csproj嵌入式资源中标记文件,我甚至尝试过无效.
<ItemGroup>
<Content Include="Infrastructure\Content\Store\content_store_en.json" />
<EmbeddedResource Include="Infrastructure\Content\Store\content_store_en.json">
</EmbeddedResource>
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
有什么办法可以实现吗?
我将应用程序从.NET Core 1.0升级到1.1.在这个过程中,dotnet构建命令使用.csproj项目文件启动,所以我摆脱了旧的project.json文件.一切都很好,直到我尝试运行docker build命令:
docker build -t sample.
当它到达Dockerfile中的RUN ["dotnet","build"]命令时,我收到一个错误:
Sending build context to Docker daemon 3.418 MB
Step 1 : FROM microsoft/dotnet:latest
---> 3693707d4f7f
Step 2 : COPY . /app
---> 771e2b035ea1
Removing intermediate container c271f962518e
Step 3 : WORKDIR /app
---> Running in 6a07c60bab1d
---> e819bc2a9e25
Removing intermediate container 6a07c60bab1d
Step 4 : RUN dotnet restore
---> Running in 99d1cf514fa3
warn : The folder '/app' does not contain a project to restore.
---> cf063f4db808
Removing intermediate container 99d1cf514fa3 …Run Code Online (Sandbox Code Playgroud) 我想在.csproj文件中添加一个自定义目标。
自定义目标将是:
msbuild /t:assembleDebug
该目标将仅使用调试模式进行构建。
我已经尝试修改.csproj文件,但没有成功。
感谢您的回答。
编辑
有关信息,我正在使用VS Code在macOS上进行开发
我正在尝试在发布过程中包括文件(当前cshtml代表我的电子邮件模板)。
我在github上关注了这个线程,但似乎他们的解决方案对我不起作用。
在这里我的csproj添加一个唯一的cshtml文件:
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
<ItemGroup>
<EmailFile Include="$(ProjectDir)/EmailTemplates/OrderCompleteEmail.cshtml" />
</ItemGroup>
<Copy SourceFiles="@(EmailFile)" DestinationFolder="$(PublishDir)" SkipUnchangedFiles="false" />
</Target>
Run Code Online (Sandbox Code Playgroud) csproj ×10
msbuild ×5
c# ×3
.net-core ×2
alias ×1
asp.net-core ×1
dll ×1
docker ×1
dockerfile ×1
file ×1
nuget ×1
operators ×1
powershell ×1
reference ×1
select-xml ×1
shortcut ×1
sonarqube ×1
xpath ×1