How to have MSBuild quiet output but with error/warning summary - msbuild

I'm simply trying to get no output from a build except the error/warning summary at the end. Not exactly a demanding task.
The command line:
msbuild.exe /nologo /verbosity:quiet /consoleloggerparameters:summary project.sln
As described here: http://msdn.microsoft.com/en-us/library/ms164311.aspx
It appears MSBuild isn't working as it should - there is no output at all. with /verbosity:normal there is tonnes of output and a useful error/warning summary at the end, is there any way of just not seeing the noise?
MSBuild reports version 12.0.21005.1 as distributed with Studio Express 2013.

late to the party, but MSBuild has the option /verbosity:quiet now and it doesn't print out anything beside error and warnings.
You can specify the following verbosity levels:
q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]
Documentation source: https://msdn.microsoft.com/en-us/library/ms164311.aspx

Use /consoleloggerparameters:ErrorsOnly or clp:ErrorsOnly to solve your problem.

I don't think there is a set of options thet matches what you want exactly. But since you're on the commandline anyway, using findstr/grep/tail and the likes is always a good option. Here's an example using powershell to display the summary and what comes after it
powershell -Command "msbuild.exe /nologo project.sln |
Select-String 'Build succeeded|failed' -Context 0, 100"
Another possibility is to use a custom logger, which is not hard as it sounds at first and there are tons of examples on the net. Plus it has the benefit you can get any custom output you want. Here's code to replicate the summary:
using System;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
public class CustomLogger : Logger
{
private int warnings = 0;
private int errors = 0;
public override void Initialize( IEventSource eventSource )
{
eventSource.WarningRaised += ( s, e ) => ++warnings;
eventSource.ErrorRaised += ( s, e ) => ++errors;
eventSource.BuildFinished += ( s, e ) =>
{
Console.WriteLine( errors == 0 ? "Build succeeded." : "Build failed." );
Console.WriteLine( String.Format( " {0} Warning(s)", warnings ) );
Console.WriteLine( String.Format( " {0} Error(s)", errors ) );
};
}
}
Put this in a file CustomLogger.cs and compile it:
csc /t:library CustomLogger.cs /reference:Microsoft.Build.Utilities.v4.0.dll;Microsoft.Build.Framework.dll
which creates a CustomLogger dll file. Now use it like this:
msbuild /nologo /logger:CustomLogger.dll /noconsolelogger project.sln

Use /verbosity:minimal instead. This prints much less, but not nothing.

Related

Can Exec task in msbuild fail if exitCode = 0 but there is logging to standard error?

I am curious about:
https://learn.microsoft.com/en-us/visualstudio/msbuild/exec-task?view=vs-2019
ExitCode Optional Int32 output read-only parameter.
Specifies the exit code that is provided by the executed command, except that if the task logged any errors, but the process had an exit code of 0 (success), ExitCode is set to -1.
Can msbuild fail on Exec even if process has an exit code of 0 but it logs to standard error?
I tried to make it fail with the following code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3
{
class Program
{
static int Main( string[] args )
{
using ( var stdErr = Console.Error )
{
for ( int i = 0; i <= 100; i++ )
{
stdErr.WriteLine( $"Failed to copy attempt {i}." );
System.Threading.Thread.Sleep( 50 );
}
// Close redirected error stream.
Console.Error.Close();
}
return 0;
}
}
}
It is being called as part of a standard props file.
<Target
Name = "IvaraSign"
AfterTargets="CoreBuild"
BeforeTargets="CopyFilesToOutputDirectory" >
<!-- Update version on main output -->
<!-- this works when the solution being compiled is in the dotnet folder. -->
<Exec Command="C:\Users\Derek.Morin\source\repos\ConsoleApp3\bin\Debug\ConsoleApp3.exe"/>
</Target>
When I build in msbuild I can see the error text in the build output but the compiling passes.
Does the MSBuild Exec task search STDOUT for the string "error"?
I was able to duplicate making exec file fail with the following
static int Main( string[] args )
{
using ( var stdErr = Console.Error )
{
stdErr.WriteLine( $#"signtool.exe : error information: ""Error: Store IsDiskFile() failed."" (-2147024864/0x80070020) [d:\work\1\s\common\MAFPlugins\MAFScripting\Contracts\Contracts.csproj]" );
}
Console.WriteLine( "but I'm still going to return 0" );
return 0;
}
The workaround is to use IgnoreStandardErrorWarningFormat="true".
<Exec Command="C:\ConsoleApp3\ConsoleApp3.exe" IgnoreStandardErrorWarningFormat="true" />

Is there QMake analogue for ".." from bash?

I'm writing a unit test using QtTest framework. I have a .pro file representing test project where i want to specify a relative path to the source files i want to test with INCLUDEPATH keyword. The source files are in the source folder, which is 2 levels above the .pro file in folder hierarchy. So, if i were to get there with bash i would go with cd .. then cd .. then cd source. I tried INCLUDEPATH += $$PWD/../../source, but this doesn't seem to work. I also couldn't find any related info in Qt docs.
How can i achieve the behaviour i want from qmake? Any help would be great.
There is a builtin (replace) function called clean_path. Documented here.
The following code did the trick for me:
defineReplace(cleanPath) {
win32:1 ~= s|\\\\|/|g
contains(1, ^/.*):pfx = /
else:pfx =
segs = $$split(1, /)
out =
for(seg, segs) {
equals(seg, ..):out = $$member(out, 0, -2)
else:!equals(seg, .):out += $$seg
}
win32:return($$join(out, \\, $$pfx))
return($$join(out, /, $$pfx))
}
srs_path = $$_PRO_FILE_PWD_/../../source
srs_path_clean = $$cleanPath($$srs_path)
INCLUDEPATH += $$srs_path_clean

How to get the result of the KieSession build (i.e. the rules compiler errors)?

I am testing DROOLS 7.0 with a simple test Rule set using the following code:
KieContainer kc = KieServices.Factory.get().getKieClasspathContainer();
KieSession ksession = kc.newKieSession("DroolsTestKS");
...
The KieSession instance is returned even if there are errors in the rule .drl file, and no exception is thrown. I would like to check the result of the rules compilation.
The Drools reference (see 4.2.2.4) says that the build result can be obtained with:
KieServices kieServices = KieServices.Factory.get();
KieBuilder kieBuilder = kieServices.newKieBuilder( kfs ).buildAll();
assertEquals( 0, kieBuilder.getResults().getMessages( Message.Level.ERROR ).size() );
where kfs is a KieFileSystem instance, but the examples on how to build such a KieFileSystem in the previous pages of the manual are much more complex and a little bit confused IMHO.
Is there a way to have the Session buid result (i.e. to access a KieBuilder ) when creating a the KieSession with the simple two lines of code I show at the beginning of this post ?
I am answering to my question, because I've just found a solution:
KieContainer kc = KieServices.Factory.get().getKieClasspathContainer();
Results rs = kc.verify("KBase");
if (rs.hasMessages(Level.ERROR)) {
System.out.println("ERRORI DROOLS: " + rs.getMessages());
... // handle this
}
I'm wondering if with this validation the actual rules compilation is executed twice or not ... but anyway this method seems to work.

List all Defined MSBuild Variables - Equivalent to set

Is there a way to list all defined variables in an executing MSBuild project?
I'm trying to figure out exactly what paths and variables are set (to pass into WiX), and it's difficult to debug everything. Essentially, I would like something equivelent to running set at the command line. Example:
C:\Users\dsokol>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\dsokol\AppData\Roaming
asl.log=Destination=file
CLASSPATH=.;C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
...
Except that I would like it to list out all of the MSBuild variables (such as Target, OutDir?, and all the crap I've defined in the top of the XML file. Ideally:
$(OutDir)="C:\MyOutDir\bin"
$(ProductVersion)="6.1.0"
$(Platform)="Win32"
Does such a thing exist?
Have you tried running msbuild with with /v:diag command line option? This prints out all of the properties which includes the environment variables and the properties that have been set.
I bingoogled everywhere and couldn't find anything about existing code that does it, so I came with my own approach.
First - you build a project with msbuild using the preprocess/pp parameter to put all the linked projects to a single file.
C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /verbosity:detailed /fl /p:Configuration=Debug /p:Platform=x86 MyApp.csproj /pp:flatproject.proj >detailedlog.txt
That already gives you a single project xml file with all properties that were set (perhaps except the environment variables or the ones passed with the /p parameter to msbuild or perhaps some others that might be set otherwise). For me that's over 800 properties. Now if you want to compile a list in alphabetical order - you could do that with a little bit of code - in my case C# and XAML:
<Window x:Class="WpfApplication4.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication4"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBox
x:Name="tb"
VerticalAlignment="Stretch"
HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Visible"/>
</Grid>
</Window>
C# bit:
public partial class MainWindow : Window
{
Dictionary<string,string> properties = new Dictionary<string, string>();
public MainWindow()
{
InitializeComponent();
var xml = new XmlDocument();
xml.LoadXml(File.ReadAllText(#"c:\git\Photos\Photos\AppStubCS\AppStubCS.Windows\x.prop"));
PopulateProperties(xml);
SortAndOutput();
}
private void SortAndOutput()
{
var sb = new StringBuilder();
foreach (var kvp in properties.OrderBy(kvp => kvp.Key))
{
sb.AppendFormat("{0}: {1}\r\n", kvp.Key, kvp.Value);
}
this.tb.Text = sb.ToString();
}
private void PopulateProperties(XmlNode xml)
{
if (xml.Name == "PropertyGroup")
{
foreach (var childNode in xml.ChildNodes.OfType<XmlElement>())
{
var name = childNode.Name;
var val = childNode.InnerText;
if (properties.ContainsKey(name))
{
properties[name] = val;
}
else
{
properties.Add(name, val);
}
}
}
else
{
foreach (var childNode in xml.ChildNodes.OfType<XmlElement>())
{
PopulateProperties(childNode);
}
}
}
}
My list:
_AdjustedPlatform
_AppContainsManagedCodeForInjection
_AppContainsManagedCodeInItsClosure
_AppxBundlePlatformsForNamingIntermediate
_AppxManifestXmlFileName
_AppxMSBuildTaskAssembly
_AppxMSBuildToolsPath
_AppxPackageConfiguration
_AssemblyTimestampAfterCompile
_AssemblyTimestampBeforeCompile
_ContinueOnError
_ConvertedPlatform
_CoreRuntimeMSBuildTaskAssembly
_CoreRuntimePackageId
_CreateAppxBundleFilesDependsOn
_CreateAppxBundlePlatformSpecificArtifactsDependsOn
_CreateAppxPackageDependsOn
_CustomAppxManifestUsed
_DebugSymbolsProduced
_DeploymentApplicationDir
_DeploymentApplicationFolderName
_DeploymentApplicationManifestIdentity
_DeploymentApplicationUrl
_DeploymentBaseManifest
_DeploymentBuiltMinimumRequiredVersion
_DeploymentBuiltUpdateInterval
_DeploymentBuiltUpdateIntervalUnits
_DeploymentComponentsUrl
_DeploymentCopyApplicationManifest
_DeploymentDeployManifestIdentity
_DeploymentFileMappingExtension
_DeploymentManifestType
_DeploymentManifestVersion
_DeploymentPublishableProjectDefault
_DeploymentTargetApplicationManifestFileName
_DeploymentUrl
_DocumentationFileProduced
_EmbedFileResfilePath
_ExtractPlatforms
_FileNameToRemove
_FileToBuild
_FindDependencies
_FrameworkSdkNames
_GatekeeperCmd
_GatekeeperPlatformTarget
_GCTODIKeepDuplicates
_GCTODIKeepMetadata
_GenerateAppxManifestDependsOn
_GenerateAppxPackageBaseDependsOn
_GenerateAppxPackageDependsOn
_GenerateAppxPackageRecipeDependsOn
_GenerateAppxUploadPackageRecipeDependsOn
_GenerateBindingRedirectsIntermediateAppConfig
_GenerateProjectPriFileDependsOn
_GetChildProjectCopyToOutputDirectoryItems
_GetPackagePropertiesDependsOn
_IlcBuildType
_IlcExePath
_IlcExitCode
_IlcExternalReferencePath
_IlcFrameworkDependencies
_IlcInputPath
_IlcIntermediatePath
_IlcInvocationParameters
_IlcKeepIntermediates
_IlcMinBehavioralExitCode
_IlcParameters
_IlcResponseFile
_IlcRootPath
_IlcSharedAssemblyDefinitionFile
_IlcSharedAssemblyRootPath
_IlcSuppressPDBWarnings
_IlcVerbosity
_IntermediateWindowsMetadataPath
_InvalidConfigurationError
_InvalidConfigurationMessageText
_InvalidConfigurationWarning
_LayoutResfilesPath
_MultipleQualifiersPerDimensionFound
_MultipleQualifiersPerDimensionFoundPath
_NetCoreFrameworkInjectionNeeded
_NuGetRuntimeIdentifierPlatformTargetSuffix
_NuGetRuntimeIdentifierWithoutAot
_NuGetTargetFallbackMoniker
_OriginalConfiguration
_OriginalPlatform
_PackagingOutputsIncludesFramework
_PdbOutputRoot
_PlatformTargetForCoreRuntime
_PlatformTargetForIlcVersion
_PriConfigXmlPath
_PriResfilesPath
_ProjectArchitectureOutput
_ProjectArchitecturesFilePath
_ProjectDefaultTargets
_ProjectNPlatformSupported
_ProjectNProjectSupported
_ProjectNToolchainEnabled
_ProjectPriFileName
_ProjectPriFullPathOriginal
_ProjectSpecificProjectJsonFile
_QualifiersPath
_Rebuilding
_ResolveReferenceDependencies
_ResourcesResfilesPath
_ReverseMapProjectPriDirectory
_ReverseMapProjectPriFileName
_ReverseMapProjectPriUploadDirectory
_ReverseMapProjectPriUploadFileName
_SGenDllCreated
_SGenDllName
_SGenGenerateSerializationAssembliesConfig
_ShouldUnsetParentConfigurationAndPlatform
_SolutionConfigurationContentsToUse
_StoreManifestSchemaDir
_SupportEmbedFileResources
_SupportXbfAsEmbedFileResources
_TargetPlatform
_TargetPlatformIsWindowsPhone
_TargetPlatformMetadataPath
_TargetsCoreRuntime
_TargetToBuild
_TransformedAppxManifestXmlFile
_TransformedProjectPriFullPath
_WindowsMetadataOutputPath
_WindowsSDKSignToolPath
_WinMDDebugSymbolsOutputPath
_WinMDDocFileOutputPath
_WireUpCoreRuntimeExitCode
_WireUpCoreRuntimeMsg
_WireUpCoreRuntimeTaskExecuted
_XamlTemporaryAssemblyPath_
AddAppConfigToBuildOutputs
AddBuildInfoToAssembly
AddSyntheticProjectReferencesForSolutionDependencies
AfterBuildLinkTargets
AllOutputGroupsDependsOn
AllowedPlatformsForProjectN
AllowedReferenceAssemblyFileExtensions
AllowedReferenceRelatedFileExtensions
AllowLocalNetworkLoopback
AltPlatformTarget
AlwaysUseNumericalSuffixInItemNames
AppConfig
AppConfigForCompiler
AppDesignerFolder
AppLocalMetadataPath
AppxBundle
AppxBundleAutoResourcePackageQualifiers
AppxBundleDefaultValueUsed
AppxBundleDir
AppxBundleExtension
AppxBundleFolderSuffix
AppxBundleMainPackageFileMapGeneratedFilesListPath
AppxBundleMainPackageFileMapIntermediatePath
AppxBundleMainPackageFileMapIntermediatePrefix
AppxBundleMainPackageFileMapIntermediatePriPath
AppxBundleMainPackageFileMapPath
AppxBundleMainPackageFileMapPrefix
AppxBundleMainPackageFileMapSuffix
AppxBundleManifestVersion
AppxBundleOutput
AppxBundlePlatforms
AppxBundlePlatformsForNaming
AppxBundlePlatformSpecificArtifactsListPath
AppxBundlePlatformSpecificUploadArtifactsListPath
AppxBundlePriConfigXmlForMainPackageFileMapFileName
AppxBundlePriConfigXmlForSplittingFileName
AppxBundleProducingPlatform
AppxBundleResourcePacksProducingPlatform
AppxBundleSplitResourcesGeneratedFilesListPath
AppxBundleSplitResourcesPriPath
AppxBundleSplitResourcesPriPrefix
AppxBundleSplitResourcesQualifiersPath
AppxCopyLocalFilesOutputGroupIncludeXmlFiles
AppxDefaultHashAlgorithmId
AppxDefaultResourceQualifiers
AppxDefaultResourceQualifiers_UAP
AppxDefaultResourceQualifiers_Windows_80
AppxDefaultResourceQualifiers_Windows_81
AppxDefaultResourceQualifiers_Windows_82
AppxDefaultResourceQualifiers_Windows_Phone
AppxFilterOutUnusedLanguagesResourceFileMaps
AppxGeneratePackageRecipeEnabled
AppxGeneratePriEnabled
AppxGeneratePrisForPortableLibrariesEnabled
AppxGetPackagePropertiesEnabled
AppxHarvestWinmdRegistration
AppxHashAlgorithmId
AppxIntermediateExtension
AppxLayoutDir
AppxLayoutFolderName
AppxMainPackageOutput
AppxMSBuildTaskAssembly
AppxMSBuildToolsPath
AppxOSMaxVersionTested
AppxOSMaxVersionTestedReplaceManifestVersion
AppxOSMinVersion
AppxOSMinVersionReplaceManifestVersion
AppxPackage
AppxPackageAllowDebugFrameworkReferencesInManifest
AppxPackageArtifactsDir
AppxPackageDir
AppxPackageDirInProjectDir
AppxPackageDirName
AppxPackageDirWasSpecified
AppxPackageExtension
AppxPackageFileMap
AppxPackageIncludePrivateSymbols
AppxPackageIsForStore
AppxPackageName
AppxPackageNameNeutral
AppxPackageOutput
AppxPackagePipelineVersion
AppxPackageRecipe
AppxPackageSigningEnabled
AppxPackageTestDir
AppxPackageValidationEnabled
AppxPackagingArchitecture
AppxPackagingInfoFile
AppxPPPrefix
AppxPrependPriInitialPath
AppxPriConfigXmlDefaultSnippetPath
AppxPriConfigXmlPackagingSnippetPath
AppxPriInitialPath
AppxResourcePackOutputBase
AppxSkipUnchangedFiles
AppxStoreContainer
AppxStoreContainerExtension
AppxStrictManifestValidationEnabled
AppxSymbolPackageEnabled
AppxSymbolPackageExtension
AppxSymbolPackageOutput
AppxSymbolStrippedDir
AppxTestLayoutEnabled
AppxUploadBundleDir
AppxUploadBundleMainPackageFileMapGeneratedFilesListPath
AppxUploadBundleMainPackageFileMapIntermediatePath
AppxUploadBundleMainPackageFileMapIntermediatePriPath
AppxUploadBundleMainPackageFileMapPath
AppxUploadBundleOutput
AppxUploadBundlePriConfigXmlForMainPackageFileMapFileName
AppxUploadBundlePriConfigXmlForSplittingFileName
AppxUploadBundleSplitResourcesGeneratedFilesListPath
AppxUploadBundleSplitResourcesPriPath
AppxUploadBundleSplitResourcesQualifiersPath
AppxUploadLayoutDir
AppxUploadLayoutFolderName
AppxUploadMainPackageOutput
AppxUploadPackageArtifactsDir
AppxUploadPackageDir
AppxUploadPackageFileMap
AppxUploadPackageOutput
AppxUploadPackageRecipe
AppxUploadPackagingInfoFile
AppxUploadSymbolPackageOutput
AppxUploadSymbolStrippedDir
AppxUseHardlinksIfPossible
AppxUseResourceIndexerApi
AppxValidateAppxManifest
AppxValidateStoreManifest
AssemblyFile
AssemblyFoldersSuffix
AssemblyName
AssemblySearchPaths
AssignTargetPathsDependsOn
AutoIncrementPackageRevision
AutoUnifyAssemblyReferences
AvailablePlatforms
BaseIntermediateOutputPath
BaseNuGetRuntimeIdentifier
BeforeRunGatekeeperTargets
BuildAppxSideloadPackageForUap
BuildAppxUploadPackageForUap
BuildCompileAction
BuildDependsOn
BuildGenerateSourcesAction
BuildId
BuildInfoBinPath
BuildInfoConfigFileName
BuildInfoFileName
BuildInfoPath
BuildInfoResourceFileName
BuildInfoResourceLogicalName
BuildInfoTargets
BuildingInTeamBuild
BuildingProject
BuildInParallel
BuildLabel
BuildLinkAction
BuildProjectReferences
BuildTimestamp
BuiltProjectOutputGroupDependsOn
CAExcludePath
CanUseProjectN
CleanDependsOn
CleanFile
CleanPackageAction
CodeAnalysisApplyLogFileXsl
CodeAnalysisFailOnMissingRules
CodeAnalysisForceOutput
CodeAnalysisGenerateSuccessFile
CodeAnalysisIgnoreGeneratedCode
CodeAnalysisIgnoreInvalidTargets
CodeAnalysisIgnoreMissingIndirectReferences
CodeAnalysisInputAssembly
CodeAnalysisLogFile
CodeAnalysisModuleSuppressionsFile
CodeAnalysisOutputToConsole
CodeAnalysisOverrideRuleVisibilities
CodeAnalysisPath
CodeAnalysisQuiet
CodeAnalysisRuleDirectories
CodeAnalysisRuleSet
CodeAnalysisRuleSetDirectories
CodeAnalysisSaveMessagesToReport
CodeAnalysisSearchGlobalAssemblyCache
CodeAnalysisStaticAnalysisDirectory
CodeAnalysisSucceededFile
CodeAnalysisSummary
CodeAnalysisTargets
CodeAnalysisTimeout
CodeAnalysisTLogFile
CodeAnalysisTreatWarningsAsErrors
CodeAnalysisUpdateProject
CodeAnalysisUseTypeNameInSuppression
CodeAnalysisVerbose
CodeAnalysisVSSku
ComFilesOutputGroupDependsOn
CommonTargetsPath
CommonXamlResourcesDirectory
CompileDependsOn
CompileLicxFilesDependsOn
CompileTargetNameForTemporaryAssembly
ComputeIntermediateSatelliteAssembliesDependsOn
ComReferenceExecuteAsTool
ComReferenceNoClassMembers
Configuration
ConfigurationName
ConsiderPlatformAsProcessorArchitecture
ContentFilesProjectOutputGroupDependsOn
ContinueOnError
CopyBuildOutputToOutputDirectory
CopyLocalFilesOutputGroupDependsOn
CopyNuGetImplementations
CopyOutputSymbolsToOutputDirectory
CopyWinmdArtifactsOutputGroupDependsOn
CoreBuildDependsOn
CoreCleanDependsOn
CoreCompileDependsOn
CoreResGenDependsOn
CoreRuntimeSDKLocation
CoreRuntimeSDKName
CreateCustomManifestResourceNamesDependsOn
CreateHardLinksForCopyAdditionalFilesIfPossible
CreateHardLinksForCopyFilesToOutputDirectoryIfPossible
CreateHardLinksForCopyLocalIfPossible
CreateHardLinksForPublishFilesIfPossible
CreateManifestResourceNamesDependsOn
CreateSatelliteAssembliesDependsOn
CscToolPath
CSharpCoreTargetsPath
CSharpTargetsPath
CURRENTVSINSTALLDIR
CustomAfterMicrosoftCommonProps
CustomAfterMicrosoftCommonTargets
CustomAfterMicrosoftCSharpTargets
CustomBeforeMicrosoftCommonProps
CustomBeforeMicrosoftCommonTargets
CustomBeforeMicrosoftCSharpTargets
CustomVersionNumber_Build
CustomVersionNumber_Build2
CustomVersionNumber_FullVersion
CustomVersionNumber_Major
CustomVersionNumber_Minor
CustomVersionNumber_Revision
CVN_Len
DebugSymbols
DebugSymbolsProjectOutputGroupDependsOn
DebugType
DefaultLanguage
DefaultLanguageSourceExtension
DeferredValidationErrorsFileName
DefineCommonCapabilities
DefineCommonItemSchemas
DefineCommonReferenceSchemas
DefineConstants
DelaySign
DesignTimeAssemblySearchPaths
DesignTimeAutoUnify
DesignTimeFindDependencies
DesignTimeFindRelatedFiles
DesignTimeFindSatellites
DesignTimeFindSerializationAssemblies
DesignTimeIgnoreVersionForFrameworkReferences
DesignTimeIntermediateOutputPath
DesignTimeResolveAssemblyReferencesDependsOn
DesignTimeResolveAssemblyReferencesStateFile
DesignTimeSilentResolution
DevEnvDir
DisableXbfGeneration
DocumentationProjectOutputGroupDependsOn
DotNetNativeRuntimeSDKMoniker
DotNetNativeSharedAssemblySDKMoniker
DotNetNativeTargetConfiguration
DotNetNativeVCLibsDependencySDKMoniker
DTARUseReferencesFromProject
EmbeddedWin32Manifest
EnableAppLocalFXWorkaround
EnableDotNetNativeCompatibleProfile
EnableFavorites
EnableNDE
EnableSigningChecks
ErrorEndLocation
ErrorReport
ExpandSDKAllowedReferenceExtensions
ExpandSDKReferencesDependsOn
ExportWinMDFile
ExtensionsToDeleteOnClean
ExtPackagesRoot
FacadeWinmdPath
FaceNextSdkRoot
FaceSdk_Bin_Path
FaceSdk_Inc_Path
FaceSdkWrapperRoot
FakesBinPath
FakesCommandLineArguments
FakesCompilationProperties
FakesContinueOnError
FakesGenerateBeforeBuildDependsOn
FakesImported
FakesIntermediatePath
FakesMSBuildPath
FakesOutputPath
FakesResolveAssemblyReferencesStateFile
FakesTargets
FakesTasks
FakesToolsPath
FakesVerbosity
FallbackCulture
FileAlignment
FinalAppxManifestName
FinalAppxPackageRecipe
FinalAppxUploadManifestName
FinalAppxUploadPackageRecipe
FinalDefineConstants
FindInvalidProjectReferences
FindInvalidProjectReferencesDependsOn
Framework20Dir
Framework30Dir
Framework35Dir
Framework40Dir
FrameworkDir
FrameworkInjectionLockFile
FrameworkInjectionPackagesDirectory
FrameworkPathOverride
FrameworkRegistryBase
FrameworkSDKDir
FullReferenceAssemblyNames
GenerateAdditionalSources
GenerateAppxPackageOnBuild
GenerateBindingRedirectsOutputType
GenerateBuildInfoConfigFile
GenerateClickOnceManifests
GenerateCompiledExpressionsTempFilePathForEditing
GenerateCompiledExpressionsTempFilePathForTypeInfer
GenerateCompiledExpressionsTempFilePathForValidation
GenerateManifestsDependsOn
GenerateResourceMSBuildArchitecture
GenerateResourceMSBuildRuntime
GenerateTargetFrameworkAttribute
GetCopyToOutputDirectoryItemsDependsOn
GetFrameworkPathsDependsOn
GetPackagingOutputsDependsOn
GetTargetPathDependsOn
GetTargetPathWithTargetPlatformMonikerDependsOn
HasSharedItems
HighEntropyVA
IlcIntermediateRootPath
IlcOutputPath
IlcParameters
ILCPDBDir
IlcTargetPlatformSdkLibPath
ImplicitlyExpandTargetFramework
ImplicitlyExpandTargetFrameworkDependsOn
ImplicitlyExpandTargetPlatform
Import_RootNamespace
ImportXamlTargets
IncludeBuiltProjectOutputGroup
IncludeComFilesOutputGroup
IncludeContentFilesProjectOutputGroup
IncludeCopyLocalFilesOutputGroup
IncludeCopyWinmdArtifactsOutputGroup
IncludeCustomOutputGroupForPackaging
IncludeDebugSymbolsProjectOutputGroup
IncludeDocumentationProjectOutputGroup
IncludeFrameworkReferencesFromNuGet
IncludeGetResolvedSDKReferences
IncludePriFilesOutputGroup
IncludeProjectPriFile
IncludeSatelliteDllsProjectOutputGroup
IncludeSDKRedistOutputGroup
IncludeServerNameInBuildInfo
IncludeSGenFilesOutputGroup
IncludeSourceFilesProjectOutputGroup
InProcessMakePriExtensionPath
InsertReverseMap
IntermediateOutputPath
IntermediateUploadOutputPath
InternalBuildOutDir
InternalBuildOutputPath
InteropOutputPath
Language
LayoutDir
LCMSBuildArchitecture
LoadTimeSensitiveProperties
LoadTimeSensitiveTargets
LocalAssembly
LocalEspcPath
LumiaPlatform
MakeAppxExeFullPath
MakePriExeFullPath
MakePriExtensionPath
MakePriExtensionPath_x64
ManagedWinmdInprocImplementation
MarkupCompilePass1DependsOn
MarkupCompilePass2DependsOn
MaxTargetPath
MergedOutputCodeAnalysisFile
MergeInputCodeAnalysisFiles
MetadataNamespaceUri
MicrosoftCommonPropsHasBeenImported
MinimumVisualStudioVersion
MrmSupportLibraryArchitecture
MsAppxPackageTargets
MSBuildAllProjects
MSBuildExtensionsPath64Exists
MsTestToolsTargets
NativeCodeAnalysisTLogFile
NetfxCoreRuntimeSettingsTargets
NetfxCoreRuntimeTargets
NoCompilerStandardLib
NonExistentFile
NoStdLib
NoWarn
NoWin32Manifest
NuGetProps
NuGetRuntimeIdentifier
NuGetTargetFrameworkMonikerToInject
NuGetTargetMoniker
NuGetTargetMonikerToInject
NuGetTargets
OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration
OnXamlPreCompileErrorTarget
Optimize
OsVersion
OutDir
OutDirWasSpecified
OutOfProcessMakePriExtensionPath
OutputPath
OutputType
OverwriteReadOnlyFiles
PackageAction
PackageCertificateKeyFile
PackagingDirectoryWritesLogPath
PackagingFileWritesLogPath
PdbCopyExeFullPath
PdbFile
PdbOutputDir
Platform
PlatformName
PlatformSpecificBundleArtifactsListDir
PlatformSpecificBundleArtifactsListDirInProjectDir
PlatformSpecificBundleArtifactsListDirName
PlatformSpecificBundleArtifactsListDirWasSpecified
PlatformSpecificUploadBundleArtifactsListDir
PlatformSpecificUploadBundleArtifactsListDirInProjectDir
PlatformTarget
PlatformTargetAsMSBuildArchitecture
PlatformTargetAsMSBuildArchitectureExplicitlySet
PostBuildEventDependsOn
PreBuildEventDependsOn
Prefer32Bit
PreferredUILang
Prep_ComputeProcessXamlFilesDependsOn
PrepareForBuildDependsOn
PrepareForRunDependsOn
PrepareLayoutDependsOn
PrepareLibraryLayoutDependsOn
PrepareResourceNamesDependsOn
PrepareResourcesDependsOn
PrevWarningLevel
PriIndexName
ProcessorArchitecture
ProcessorArchitectureAsPlatform
ProduceAppxBundle
ProgFiles32
ProjectDesignTimeAssemblyResolutionSearchPaths
ProjectDir
ProjectExt
ProjectFileName
ProjectFlavor
ProjectGuid
ProjectLockFile
ProjectName
ProjectNProfileEnabled
ProjectNSettingsTargets
ProjectNTargets
ProjectPath
ProjectPriFileName
ProjectPriFullPath
ProjectPriIndexName
ProjectPriUploadFullPath
ProjectTypeGuids
PublishableProject
PublishBuildDependsOn
PublishDependsOn
PublishDir
PublishOnlyDependsOn
PublishPipelineCollectFilesCore
RebuildDependsOn
RebuildPackageAction
RedirectionTarget
RegisterAssemblyMSBuildArchitecture
RegisterAssemblyMSBuildRuntime
RemoveAssemblyFoldersIfNoTargetFramework
ReportingServicesTargets
ResGenDependsOn
ResGenExecuteAsTool
ResgenToolPath
ResolveAssemblyReferencesDependsOn
ResolveAssemblyReferencesSilent
ResolveAssemblyReferencesStateFile
ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch
ResolveComReferenceMSBuildArchitecture
ResolveComReferenceSilent
ResolveComReferenceToolPath
ResolveNuGetPackageAssetsDependsOn
ResolveNuGetPackages
ResolveReferencesDependsOn
ResolveSDKReferencesDependsOn
RootNamespace
RunCodeAnalysisDependsOn
RunCodeAnalysisInputs
RunCodeAnalysisOnThisProject
RunDependsOn
RunMergeNativeCodeAnalysisDependsOn
RunNativeCodeAnalysisInputs
SafeIntDir
SatelliteDllsProjectOutputGroupDependsOn
SDKExtensionDirectoryRoot
SDKIdentifier
SDKRedistOutputGroupDependsOn
SDKReferenceDirectoryRoot
SDKReferenceRegistryRoot
SDKReferenceWarnOnMissingMaxPlatformVersion
SDKRefVersionToUse
SDKVersion
SDKVersionToUse
SGenFilesOutputGroupDependsOn
SGenMSBuildArchitecture
SGenShouldGenerateSerializer
SGenUseKeep
SGenUseProxyTypes
SharedGUID
ShouldMarkCertainSDKReferencesAsRuntimeOnly
ShouldUnsetParentConfigurationAndPlatform
SignAppxPackageExeFullPath
SignToolPath
SkipCopyUnchangedFiles
SkipILCompilation
SkipIntermediatePriGenerationForResourceFiles
SkipMergingFrameworkResources
SolutionDir
SolutionDirNoTrailingBackspace
SolutionExt
SolutionFileName
SolutionName
SolutionPath
SourceFilesProjectOutputGroupDependsOn
StandardBuildPipeline
StoreManifestName
StripPrivateSymbols
SubsystemVersion
SupportWindows81SDKs
SupportWindowsPhone81SDKs
SuppressWarningsInPass1
SyncLibsForDotNetNativeSharedFrameworkPackage
SynthesizeLinkMetadata
TargetCulture
TargetDeployManifestFileName
TargetDir
TargetedFrameworkDir
TargetedSDKArchitecture
TargetedSDKConfiguration
TargetExt
TargetFileName
TargetFrameworkAsMSBuildRuntime
TargetFrameworkDirectory
TargetFrameworkIdentifier
TargetFrameworkMoniker
TargetFrameworkMonikerAssemblyAttributesFileClean
TargetFrameworkMonikerAssemblyAttributesPath
TargetFrameworkMonikerAssemblyAttributeText
TargetFrameworkProfile
TargetFrameworkVersion
TargetName
TargetPath
TargetPlatformDisplayName
TargetPlatformIdentifier
TargetPlatformIdentifierWindows81
TargetPlatformIdentifierWindowsPhone81
TargetPlatformMinVersion
TargetPlatformMoniker
TargetPlatformRegistryBase
TargetPlatformResourceVersion
TargetPlatformSdkMetadataLocation
TargetPlatformSdkPath
TargetPlatformSdkRootOverride
TargetPlatformVersion
TargetPlatformVersionWindows81
TargetPlatformVersionWindowsPhone81
TargetPlatformWinMDLocation
TargetRuntime
TargetsPC
TargetsPhone
TaskKeyToken
TaskVersion
TreatWarningsAsErrors
UapAppxPackageBuildModeCI
UapAppxPackageBuildModeSideloadOnly
UapAppxPackageBuildModeStoreUpload
UapBuildPipeline
UapDefaultAssetScale
UnmanagedRegistrationDependsOn
UnmanagedUnregistrationDependsOn
UnregisterAssemblyMSBuildArchitecture
UnregisterAssemblyMSBuildRuntime
UseCommonOutputDirectory
UseDotNetNativeSharedAssemblyFrameworkPackage
UseDotNetNativeToolchain
UseHostCompilerIfAvailable
UseIncrementalAppxRegistration
UseNetNativeCustomFramework
UseOSWinMdReferences
UseRTMSdk
UseSharedCompilation
UseSourcePath
UseSubFolderForOutputDirDuringMultiPlatformBuild
UseTargetPlatformAsNuGetTargetMoniker
UseVSHostingProcess
Utf8Output
ValidatePresenceOfAppxManifestItemsDependsOn
VCInstallDir
VCLibs14SDKName
VCLibsTargetConfiguration
VersionIntDir
VisualStudioVersion
WarningLevel
WebReference_EnableLegacyEventingModel
WebReference_EnableProperties
WebReference_EnableSQLTypes
Win32Manifest
Windows8SDKInstallationFolder
WindowsAppContainer
WindowsSdkPath
WinMDExpOutputPdb
WinMDExpOutputWindowsMetadataFilename
WinMdExpToolPath
WinMdExpUTF8Ouput
WinMDOutputDocumentationFile
WireUpCoreRuntimeGates
WireUpCoreRuntimeOutputPath
WMSJSProject
WMSJSProjectDirectory
WorkflowBuildExtensionAssemblyName
WorkflowBuildExtensionKeyToken
WorkflowBuildExtensionVersion
XamlBuildTaskAssemblyName
XamlBuildTaskLocation
XamlBuildTaskPath
XAMLCompilerVersion
XAMLFingerprint
XAMLFingerprintIgnorePaths
XamlGenCodeFileNames
XamlGeneratedOutputPath
XamlGenMarkupFileNames
XamlPackagingRootFolder
XamlPass2FlagFile
XamlRequiresCompilationPass2
XamlRootsLog
XamlSavedStateFileName
XamlSavedStateFilePath
XamlTemporaryAssemblyName
XsdCodeGenCollectionTypes
XsdCodeGenEnableDataBinding
XsdCodeGenGenerateDataTypesOnly
XsdCodeGenGenerateInternalTypes
XsdCodeGenGenerateSerializableTypes
XsdCodeGenImportXmlTypes
XsdCodeGenNamespaceMappings
XsdCodeGenPreCondition
XsdCodeGenReuseTypesFlag
XsdCodeGenReuseTypesMode
XsdCodeGenSerializerMode
XsdCodeGenSupportFx35DataTypes
YieldDuringToolExecution
For some reason, /v:diagnostic did not dump the environment variables for me.
I tried some stuff, and then the sort-of obvious simple thing worked. Try:
<Exec Command='set' />
You might want to try Debugging MSBuild script with VisualStudio. I haven't tried it, but it seems like it could allow you to step through a script and also list variables.
I know this question is a little old and I'm not sure if there's actually a way to enumerate all defined property names in MSBuild parlance (I'm not aware of one), but I would recommend using the /bl (/binlog[:filename]) switch and loading the resulting binary log in the MSBuild Binary and Structured Log Viewer which will not only tell you every property defined and its value, but also show what the values were as each target or task is called throughout the build. This tool has been incredibly useful for learning the inner workings and finding appropriate extension points when customizing MSBuild and can even take you to the line of MSBuild xml that was being executed when you double click on events in the log. There's also a Visual Studio extension mentioned on the site linked that can be used to troubleshoot design time builds (when VS calls MSBuild for things like XAML previews, etc.)

System.Type.GetCustomAttributes on an assembly loaded from a network share is not showing all attributes

I have a managed dll – repro.dll, which contains class TestModuleCommand decorated with 2 attributes: System.ObsoleteAttribute and System.Management.Automation.CmdletAttribute (comes from System.Management.Automation.dll which is in the GAC in Windows 7)
namespace Test {
[System.Obsolete]
[System.Management.Automation.Cmdlet("Test", "Module")]
public class TestModuleCommand : System.Management.Automation.PSCmdlet {
protected override void ProcessRecord() {
this.WriteObject("In test-module");
}
}
}
If repro.dll is placed in a local directory, I can see both attributes returned from System.Type.GetCustomAttributes(false). If repro.dll is placed in a network path, then I can see only one attribute (although I still see both attributes via System.Reflection.CustomAttributeData.GetCustomAttributes(MemberInfo)). This is undesired – I want to see both attributes (I know that instantiating CmdletAttribute doesn’t have a security impact).
From what I found online, I am vaguely aware that repro.dll (if loaded from network location) cannot fully see S.M.A.dll. I think that CAS allows me to declare in System.Management.Automation that CmdletAttribute is safe, but I haven’t been able to figure out how to write that declaration. Where can I read more to fully understand what is going on? Any words of wisdom are welcomed.
Thanks,
Lukasz
PS. Below is a repro that anyone can try at a powershell.exe prompt (in Windows 7 - Add-Type cmdlet is new in PowerShell v2):
PS C:\> Add-Type -TypeDefinition #"
>> namespace Test {
>> [System.Obsolete]
>> [System.Management.Automation.Cmdlet("Test", "Module")]
>> public class TestModuleCommand : System.Management.Automation.PSCmdlet {
>> protected override void ProcessRecord() {
>> this.WriteObject("In test-module");
>> }
>> }
>> }
>> "# -OutputAssembly \\axp-test\scratch\lukasza\repro.dll -OutputType Library
>>
PS C:\> # local copy would work...
PS C:\> # Copy \\axp-test\scratch\lukasza\repro.dll ~\repro.dll
PS C:\>
PS C:\> $a = [System.Reflection.Assembly]::LoadFrom("\\axp-test\scratch\lukasza\repro.dll")
PS C:\> $t = $a.GetType("Test.TestModuleCommand")
PS C:\> $t.GetCustomAttributes($false) # only 1 attribute is visible here
Message IsError TypeId
------- ------- ------
False System.ObsoleteAttribute
PS C:\>
PS C:\> [System.Reflection.CustomAttributeData]::GetCustomAttributes($t) # but I can see both attributes here
Constructor ConstructorArguments NamedArguments
----------- -------------------- --------------
Void .ctor(System.String, System.Str... {"Test", "Module"} {}
Void .ctor() {} {}
PS C:\>
PS C:\> $a.Evidence
SecurityZone
------------
Intranet
This is the answer that I found: Haibo Luo - My Attribute Disappears