.net 从命令行调用MSBuild时,避免禁用的正确方法是什么?
我尝试在参数中转义分号,如下所示:.net 从命令行调用MSBuild时,避免禁用的正确方法是什么?,.net,msbuild,aspnet-compiler,vbc,.net,Msbuild,Aspnet Compiler,Vbc,我尝试在参数中转义分号,如下所示: /fileLoggerParameters:LogFile=msbuild.log;追加绩效总结;双核矮星=1%3B2%3B3%3B40003%3B40055%3B4202%3B42021%3B42022%3B2025%3B42104%3B40003%3BC40055%3BC42020%3BC42021%3BC42022%3BC42025%3BC42104;警告级别=0;VbcVerbosity=安静/属性:不允许矮星=1%3B2%3B3%3B40003%3B
/fileLoggerParameters:LogFile=msbuild.log;追加绩效总结;双核矮星=1%3B2%3B3%3B40003%3B40055%3B4202%3B42021%3B42022%3B2025%3B42104%3B40003%3BC40055%3BC42020%3BC42021%3BC42022%3BC42025%3BC42104;警告级别=0;VbcVerbosity=安静/属性:不允许矮星=1%3B2%3B3%3B40003%3B40055%3B4200%3B42021%3B42022%3B4205%3B42004%3B40003%3B40055%3BC42020%3BC42021%BBC42022%3BC42025%3BB2104;警告级别=0;VbcVerbosity=安静
但在我的日志中,它们仍然显示为已逃逸:
Task "MSBuild"
Global Properties:
Configuration=Release
DebugSymbols=false
DisabledWarnings=1%3b2%3b3%3b40003%3b40055%3b42020%3b42021%3b42022%3b42025%3b42104%3bBC40003%3bBC40055%3bBC42020%3bBC42021%3bBC42022%3bBC42025%3bBC42104
Optimize=true
WarningLevel=0
VbcVerbosity=Quiet
我正试图抑制类似这样的警告(来自aspnet\u compiler.exe
,我假设它在引擎盖下使用vbc.exe
),我不关心这些警告:
警告BC42020:没有'As'子句的变量声明;类型 假定对象。
警告BC42021:没有'As'子句的函数; 假定对象的返回类型。
警告BC42022:没有 “As”条款;假定的对象类型。
- 等等
NoWarn
,禁用矮人功能
,/verbosity:quiet
,WarningLevel=0
和VbcVerbosity=quiet
,但似乎没有任何东西能抑制它们
更新2:以下是完整构建命令:
C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe /nologo /consoleloggerparameters:PerformanceSummary /verbosity:quiet /fileLogger /fileLoggerParameters:LogFile=msbuild.log;Append;PerformanceSummary;VbcVerbosity=Quiet;DisabledWarnings="40003;40055;42020;42021;42022;42025;42104;BC40003;BC40055;BC42020;BC42021;BC42022;BC42025;BC42104";WarningLevel=0;NoWarn="40003;40055;42020;42021;42022;42025;42104;BC40003;BC40055;BC42020;BC42021;BC42022;BC42025;BC42104" /target:JustWebSite /maxcpucount:3 "Build.proj"
和Build.proj:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="JustWebSite" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<UsingTask TaskName="Microsoft.Build.Tasks.CreateTemporaryVCProject" AssemblyName="Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<UsingTask TaskName="Microsoft.Build.Tasks.ResolveVCProjectOutput" AssemblyName="Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<PropertyGroup>
<SolutionName>WebSiteX</SolutionName>
<ProjectFolder>D:\Projects\$(SolutionName)</ProjectFolder>
<VirtualPath>\</VirtualPath>
<AspNetConfiguration>Release</AspNetConfiguration>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<AspNetVirtualPath>$(VirtualPath)</AspNetVirtualPath>
<AspNetPhysicalPath>$(ProjectFolder)\$(SolutionName)\</AspNetPhysicalPath>
<AspNetTargetPath>PrecompiledWeb\$(SolutionName)\</AspNetTargetPath>
<AspNetForce>true</AspNetForce>
<AspNetUpdateable>true</AspNetUpdateable>
<AspNetDebug>False</AspNetDebug>
<AspNetKeyFile></AspNetKeyFile>
<AspNetKeyContainer></AspNetKeyContainer>
<AspNetDelaySign></AspNetDelaySign>
<AspNetAPTCA></AspNetAPTCA>
<AspNetFixedNames>false</AspNetFixedNames>
<AspNetTargetPath Condition=" '$(OutDir)' != '' ">$(OutDir)_PublishedWebsites\$(SolutionName)\</AspNetTargetPath>
</PropertyGroup>
<Target Name="GetFrameworkPathAndRedistList">
<GetFrameworkPath>
<Output TaskParameter="Path" ItemName="_CombinedTargetFrameworkDirectoriesItem" Condition="'$(MSBuildToolsVersion)' == '2.0'" />
<Output TaskParameter="FrameworkVersion35Path" ItemName="_CombinedTargetFrameworkDirectoriesItem" Condition=" '$(TargetFrameworkVersion)' == 'v3.5' and '$(MSBuildToolsVersion)' != '2.0'" />
<Output TaskParameter="FrameworkVersion30Path" ItemName="_CombinedTargetFrameworkDirectoriesItem" Condition=" ('$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5') and '$(MSBuildToolsVersion)' != '2.0'" />
<Output TaskParameter="FrameworkVersion20Path" ItemName="_CombinedTargetFrameworkDirectoriesItem" Condition=" ('$(TargetFrameworkVersion)' == 'v2.0' or '$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5') and '$(MSBuildToolsVersion)' != '2.0'" />
</GetFrameworkPath>
<CreateItem Include="@(_CombinedTargetFrameworkDirectoriesItem->'%(Identity)\RedistList\*.xml')">
<Output TaskParameter="Include" ItemName="InstalledAssemblyTables" />
</CreateItem>
</Target>
<Target Name="JustWebSite" DependsOnTargets="GetFrameworkPathAndRedistList">
<Message Text="Just building website..." />
<CombinePath BasePath="$(AspNetPhysicalPath)" Paths="@(References_ReferenceRelPath)">
<Output TaskParameter="CombinedPaths" ItemName="References" />
</CombinePath>
<Copy SourceFiles="@(References->'%(FullPath)')" DestinationFolder="$(AspNetPhysicalPath)\Bin\" Condition="!Exists('%(References.Identity)')" ContinueOnError="true" SkipUnchangedFiles="true" />
<ResolveAssemblyReference Assemblies="@(References->'%(FullPath)')" TargetFrameworkDirectories="@(_CombinedTargetFrameworkDirectoriesItem)" InstalledAssemblyTables="@(InstalledAssemblyTables)" SearchPaths="{RawFileName};{TargetFrameworkDirectory};{GAC}" FindDependencies="true" FindSatellites="true" FindSerializationAssemblies="true" FindRelatedFiles="true" Condition="Exists('%(References.Identity)')">
<Output TaskParameter="CopyLocalFiles" ItemName="References_CopyLocalFiles" />
</ResolveAssemblyReference>
<Copy SourceFiles="@(References_CopyLocalFiles)" DestinationFiles="@(References_CopyLocalFiles->'$(AspNetPhysicalPath)\Bin\%(DestinationSubDirectory)%(Filename)%(Extension)')" Condition="(false) or ('$(AspNetConfiguration)' == 'Debug') or ('$(AspNetConfiguration)' == 'Release')" SkipUnchangedFiles="true" />
<AspNetCompiler VirtualPath="$(AspNetVirtualPath)" PhysicalPath="$(AspNetPhysicalPath)" TargetPath="$(AspNetTargetPath)" Force="$(AspNetForce)" Updateable="$(AspNetUpdateable)" Debug="$(AspNetDebug)" KeyFile="$(AspNetKeyFile)" KeyContainer="$(AspNetKeyContainer)" DelaySign="$(AspNetDelaySign)" AllowPartiallyTrustedCallers="$(AspNetAPTCA)" FixedNames="$(AspNetFixedNames)" Condition="(false) or ('$(AspNetConfiguration)' == 'Debug') or ('$(AspNetConfiguration)' == 'Release')" />
</Target>
</Project>
网站
D:\Projects\$(解决方案名称)
\
释放
v3.5
$(虚拟路径)
$(项目文件夹)\$(解决方案名称)\
预编译Web\$(解决方案名称)\
真的
真的
假的
假的
$(OutDir)\ u PublishedWebsites\$(SolutionName)\
按如下方式填充NoWarn
属性:
msbuild your.vbproj /p:NoWarn="40003,40055,42020,42021,42022,42025,42104,40003,40055"
我没有想过使用引号来转义,谢谢,我回到办公室后会尝试。它看起来接受了参数,但仍然显示了警告。不需要转义。如何运行构建?我已经用fullbuild命令更新了这个问题。使警告不显示的唯一方法是将
/noconsolelogger
传递到命令行,但这会隐藏所有内容。警告总是输出到日志文件中。(我尝试使用逗号和分号)您在NoWarn
之前省略了/p:
或/property:
开关您是否尝试过在使用Visual Studio编译并查看它显示的命令行时忽略警告?(我不想在我的VS计算机上亲自尝试。)Mark,这已经有一段时间了,所以我会看一看,但我非常确定Visual Studio的构建没有与msbuild相同的命令行设置。