我需要创建多个/ testcontainer:参数来提供给exec的MsTest的任务.
我有以下内容:
<ItemGroup>
<TestFiles Include="$(ProjectPath)\**\UnitTest.*.dll" />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
对于TestFiles中的每个匹配,我想构建一个像这样的字符串:
"/testcontainer:UnitTest.SomeLibrary1.dll"
"/testcontainer:UnitTest.SomeLibrary2.dll"
"/testcontainer:UnitTest.SomeLibrary3.dll"
Run Code Online (Sandbox Code Playgroud)
我试图使用MSBuild的内部而不必创建自定义任务,这可能吗?
TIA
我写了一个MsBuild任务:MyTask.在我的解决方案中,我有Task项目和其他项目.MyTask引用了一个引用第三个程序集的项目(比如ProjA),比如说(dep1和dep2).
这些项目都构建良好,我将输出放在一个目录(Compil)中.在这个目录中我有我想要的所有dll:MyTask.dll,ProjA.dll,dep1.dll,dep2.dll等.
在我的MsBuild文件中,我包含自定义任务程序集:
<UsingTask AssemblyFile="..\Compil\MyTask.dll" TaskName="CreateSitesCss" />
Run Code Online (Sandbox Code Playgroud)
然后我调用MyTask程序集的任务.该调用执行得很好但是MsBuild抱怨没有找到dep1和dep2程序集(尽管它们位于同一目录中):
错误:无法加载文件或程序集'dep1,Version = 2.0.0.0,Culture = neutral,PublicKey Token = 9109c11469ae1bc7'或其依赖项之一.该系统找不到指定的文件.
我可以通过将dep1.dll和dep2.dll复制到c:\ windows\microsoft .net\framework\v4.0 \来解决这个问题,但我不想这样做,因为它在构建其他项目时会触发问题(赢了' t将dep1.dll和dep2.dll复制到输出目录...).
有没有人有同样的问题,或更好的解决方案?
编辑
这是Fusion Log Viewer的输出
*** Assembly Binder Log Entry (19/10/2010 @ 17:52:45) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = HEADOFFICE\bbaumann
LOG: DisplayName = ProjA
(Partial)
WRN: …Run Code Online (Sandbox Code Playgroud) msbuild dependencies msbuild-task assembly-resolution probing
我认为这很简单但后来意识到我无法在任何地方找到任何信息.
我有这样的自定义任务:
public class MyCustomTask : Task
{
[Required]
public string[] SomeStrings {get;set;}
public override bool Execute()
{
// Do something with strings...
}
}
Run Code Online (Sandbox Code Playgroud)
匹配的MSBuild东西基本上是这样的:
<UsingTask TaskName="MyCustomTask" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<SomeStrings ParameterType="System.String[]" Required="true" />
</ParameterGroup>
<Task>
...
</Task>
</UsingTask>
<Target Name="DoSomething">
<MyCustomTask SomeStrings="????" />
</Target>
Run Code Online (Sandbox Code Playgroud)
不知道在SomeStrings参数中放什么,想想也许它会理解我是否做了"xxx,xxx,xxx"所以任何人都可以对此有所了解.基本场景很像标记,所以我需要一个字符串列表然后一些比较字符串,所以我需要传入2个列表/数组,但只是难倒.
我的ClickOnce安装失败并显示错误:
File,WindowsFormsProject.exe具有与manifest中指定的不同的计算哈希值.
我使用MSBuild生成ClickOnce部署包.构建脚本中的相关行:
<MSBuild Targets="Publish"
Projects="WindowsFormsProject.csproj"
ContinueOnError="false" />
Run Code Online (Sandbox Code Playgroud)
WindowsFormsProject.csproj具有签署可执行文件的Post-Build步骤,如下所示:
signtool sign /a $(ProjectDir)\obj\$(PlatformName)\$(ConfigurationName)\$(TargetFileName)
Run Code Online (Sandbox Code Playgroud)
麻烦的是,当我查看构建日志时,我发现清单是在Post-Build事件执行之前生成的.因此哈希码不匹配就不足为奇了.构建日志中的相关行:
_CopyManifestFiles:
WindowsFormsProject - > ...\WindowsFormsProject.application
...
PostBuildEvent:
成功签名:...\WindowsFormsProject.exe
所以,问题是:
或者,如果你能想到问题的不同解决方案,我会很感激你的想法.
我有一个自定义的 MSBuild 目标,部分代码片段如下..
<Target Name="PublishHtm">
<PropertyGroup>
<PublishHtmTemplateContents>$([System.IO.File]::ReadAllText($(PublishHtmTemplatePath)))</PublishHtmTemplateContents>
<PublishHtm>$(PublishHtmTemplateContents)</PublishHtm>
</PropertyGroup>
<WriteLinesToFile Lines="$(PublishHtm)" File="$(PublishDir)\publish.htm" Overwrite="true"/>
</Target>
Run Code Online (Sandbox Code Playgroud)
这是对此解决方案的一次返工尝试,因为我试图将此模板隔离到外部文件。该模板包含 MSBuild 属性引用,例如$(ApplicationName). 当完全按照链接解决方案中的描述执行此操作时,它工作得很好,但是当将模板作为字符串加载时,这些属性表达式在到达文件时都不会被评估。
<SPAN CLASS="BannerTextApplication">$(ApplicationName)</SPAN>
Run Code Online (Sandbox Code Playgroud)
是否有一个 MSBuild 表达式/函数可以用来在给定调用目标的上下文的情况下重新评估字符串?
顺便说一句,我不想使用查找/替换或正则表达式替换来解决问题,而是坚持使用 MSBuild 表达式引擎。
使用 Visual Studio 2012 和 .NET Framework 4.5。
我不清楚 WriteCodeFragment 任务的目的是什么(https://msdn.microsoft.com/en-us/library/microsoft.build.tasks.writecodefragment.aspx)。谷歌似乎只是打开文档,我看到的一个例子并不是确定的。
有人可以澄清吗?谢谢。
目前,在使用为我们的项目定义的自定义代码分析规则集配置 ASP.Net Core 2.0 应用程序后,我收到 CA0055 和 CA0052 代码分析错误(使用 Visual Studio 2017 和使用 MSBuild 命令)。通过提供的不同解决方案尝试了不同的方法来解决这些错误,但没有运气。请帮助我们解决这些代码分析错误...
以下是错误详情
MSBUILD:错误:CA0055:无法识别“D:\Source\Temp\WebClient\Business\bin\Debug\netco reapp2.0\Business.dll”的平台。[D:\Source\Temp\WebClient\Business\Business.csproj] MSBUILD:错误:CA0052:未选择任何目标。[D:\Source\Temp\WebClient\Business\Business.csproj] 代码分析完成 -- 2 个错误,0 个警告
谢谢,维努马达夫。
更新:
\n\n似乎添加dotnet build -v d又名将详细程度设置为详细显示了有关此过程的更多细节(显然)
原来的:
\n\n参考: https: //learn.microsoft.com/en-us/nuget/reference/msbuild-targets
\n\n我正在使用dotnet build,我的 csproj 看起来像:
<Project Sdk="Microsoft.NET.Sdk">\n\n <PropertyGroup>\n <TargetFramework>netstandard2.0</TargetFramework>\n <GeneratePackageOnBuild>true</GeneratePackageOnBuild>\n <PackageOutputPath>..\\packages\\</PackageOutputPath>\n <AssemblyVersion>0.1.0</AssemblyVersion> \n </PropertyGroup>\n\n <Target Name="CopyPackage" AfterTargets="Pack">\n <Copy\n SourceFiles="$(OutputPath)..\\$(PackageId).$(PackageVersion).nupkg"\n DestinationFolder="%USERPROFILE%\\.nuget\\packages"\n />\n </Target>\n <Target Name="AfterPackMessage" AfterTargets="Pack">\n <Message Text="Copied $(OutputPath)..\\$(PackageId).$(PackageVersion).nupkg TO %USERPROFILE%\\.nuget\\packages" /> \n </Target>\n</Project>\nRun Code Online (Sandbox Code Playgroud)\n\n我只看到这个输出
\n\nC:\\code\\MySolution.net\\MyProject.Core (feature-mediator-http)\n\xce\xbb dotnet build\nMicrosoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Core\nCopyright (C) Microsoft Corporation. All rights reserved.\n\n Restore completed in 70.34 ms for C:\\code\\MySolution.net\\MyProject.Core\\MyProject.Core.csproj.\n MyProject.Core -> …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Visual Studio 中用 C# 构建 Dll。使用 NuGet RGiesecke.DllExport。然而,由于某种原因,它在构建 Dll 时返回一些错误。下面是描述。
错误
“DllExportAppDomainIsolatedTask”任务意外失败。System.ArgumentException:找不到请求的值“Version46”。
服务器堆栈跟踪:
at System.Enum.EnumResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument)
at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult)
at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
at RGiesecke.DllExport.MSBuild.ExportTaskImplementation`1.<>c__DisplayClass8.<GetGetToolPathInternal>b__7(Version version, String toolName) in c:\Users\rober_000\Documents\Code\unmanaged-exports\RGiesecke.DllExport.MSBuild\ExportTaskImplementation.cs:line 568
at RGiesecke.DllExport.MSBuild.ExportTaskImplementation`1.TryToGetToolDirForFxVersion(String toolFileName, Func`3 getToolPath, String& toolDirectory) in c:\Users\rober_000\Documents\Code\unmanaged-exports\RGiesecke.DllExport.MSBuild\ExportTaskImplementation.cs:line 725
at RGiesecke.DllExport.MSBuild.ExportTaskImplementation`1.ValidateToolPath(String toolFileName, String currentValue, Func`3 getToolPath, String& foundPath) in c:\Users\rober_000\Documents\Code\unmanaged-exports\RGiesecke.DllExport.MSBuild\ExportTaskImplementation.cs:line 698
at RGiesecke.DllExport.MSBuild.ExportTaskImplementation`1.ValidateFrameworkPath() in c:\Users\rober_000\Documents\Code\unmanaged-exports\RGiesecke.DllExport.MSBuild\ExportTaskImplementation.cs:line 680
at RGiesecke.DllExport.MSBuild.ExportTaskImplementation`1.ValidateInputValues() in c:\Users\rober_000\Documents\Code\unmanaged-exports\RGiesecke.DllExport.MSBuild\ExportTaskImplementation.cs:line 396
at RGiesecke.DllExport.MSBuild.ExportTaskImplementation`1.Execute() in …Run Code Online (Sandbox Code Playgroud) 我正在尝试从https://visualstudio.microsoft.com/downloads/下载Visual Studio 2019 的构建工具但是当我单击下载按钮时,系统会下载一个 exe,该 exe 尝试连接到 Internet 以下载软件包的其余部分。
我如何才能获得离线版本的 Visual Studio 2019构建工具或Visual Studio 2017 构建工具。
msbuild-task ×10
msbuild ×9
c# ×5
.net ×2
.net-core ×1
asp.net-core ×1
clickonce ×1
dependencies ×1
msbuild-4.0 ×1
probing ×1