Open amazinmoe opened 7 years ago
I've experimented with running a PostBuild event which runs Code Analysis using FxCopCmd.exe It works locally & outputs the log.xml file but on the VSTS build it doesn't output the issues as Warnings so I don't see them in the Issues tab once the build completes.
Here's the PostBuild event
if EXIST "c:\program files (x86)\microsoft visual studio\2017\enterprise\team tools\static analysis tools\FxCop\FxCopCmd.exe" ( echo "Found FxCopCmd.exe in c:\program files (x86)\microsoft visual studio\2017\enterprise\team tools\static analysis tools\FxCop\" "c:\program files (x86)\microsoft visual studio\2017\enterprise\team tools\static analysis tools\FxCop\FxCopCmd.exe" /outputCulture:1033 /out:"$(OutDir)bin\$(TargetFileName).CodeAnalysisLog.xml" /file:"$(OutDir)\bin\$(TargetFileName)" /searchgac /ignoreinvalidtargets /forceoutput /successfile /ignoregeneratedcode /saveMessagesToReport:Active /timeout:120 /reportMissingIndirectAssemblies ) if EXIST "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe" ( echo "Found FxCopCmd.exe in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop\" "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe" /outputCulture:1033 /out:"$(OutDir)bin\$(TargetFileName).CodeAnalysisLog.xml" /file:"$(OutDir)\bin\$(TargetFileName)" /searchgac /ignoreinvalidtargets /forceoutput /successfile /ignoregeneratedcode /saveMessagesToReport:Active /timeout:120 /reportMissingIndirectAssemblies )
Looking through the build framework there's a step to copy the .pdb to the bin folder PostBuild, if the API can be copied PostBuild as well I believe it will resolve this issue.
I made the following changes to Microsoft.NET.Sdk.Functions.build.targets which resolved the issue for me locally but I'd like to see if they can be added to the official Nuget package so it doesn't fail on the VSTS build server.
Added another Move task for the target assembly. `<Target Name="_GenerateFunctionsPostBuild" AfterTargets="Build">
<!-- TODO: CopyFilesToOutputDirectory does not look at the outdir to copy the pdbs. hence copying it manually. -->
<!-- Copy the application pdb to the bin folder-->
<Move SourceFiles="$(TargetDir)$(TargetName).pdb"
DestinationFiles="$(TargetDir)bin\$(TargetName).pdb"
OverwriteReadOnlyFiles="true"
Condition="Exists('$(TargetDir)$(TargetName).pdb')" />
<Move SourceFiles="$(TargetDir)$(TargetName).dll"
DestinationFiles="$(TargetDir)bin\$(TargetName).dll"
OverwriteReadOnlyFiles="true"
Condition="Exists('$(TargetDir)$(TargetName).dll')" />
<BuildFunctions
TargetPath="$(TargetPath)"
OutputPath="$(TargetDir)"/>
`
Removed \bin from OutDir property in _FunctionsBeforeCopyFilesToOutputDirectory section `<Target Name="_FunctionsBeforeCopyFilesToOutputDirectory" BeforeTargets="CopyFilesToOutputDirectory">
`
@soninaren
I am also facing exact issue. Do we have any solution for this? Please suggest
@soninaren ping
I tried to enable static code analysis for an Azure Function project but its failing due to the additional bin folder in the output path. Static Code Analysis is looking for the assemblies one directory up since I believe its using TargetPath directory which isn't updated to include the additional bin folder. Do you know if there's a workaround for this?
I enabled Static Code Analysis by editing the project file like so:
Azure Functions Project File `