build events for both release and debug mode - visual-studio-2010

I have the following rule for post-build events
copy "$(TargetDir)$(TargetFileName)" ..\..\impld\
It works fine for release build but when I build in debug mode I get error
MSB3073: The command "
copy "< path to dll>" ..\..\impld\
:VCEnd" exited with code 1.
Problem is that though in debug mode < project_name>d.dll file is created VS still tries to copy "release" dll (without 'd'). There was no such error with VS2008, though the code was the same.

Related

Can someone explain why I have build task error MSB3491?

When building using Visual Studio 2022, targeting net7.0, net6.0, and netstandard2.0, the build fails with the following warnings in the build output (I don't think multi-targeting has any impact):
>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(3588,5): warning MSB3491: Could not write lines to file "obj\Debug\net6.0\.NETCoreApp,Version=v6.0.AssemblyAttributes.cs". Access to the path 'D:\src\XXX\obj\Debug\net6.0\.NETCoreApp,Version=v6.0.AssemblyAttributes.cs' is denied.
>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(3588,5): warning MSB3491: Could not write lines to file "obj\Debug\net7.0\.NETCoreApp,Version=v7.0.AssemblyAttributes.cs". Access to the path 'D:\src\XXX\obj\Debug\net7.0\.NETCoreApp,Version=v7.0.AssemblyAttributes.cs' is denied.
>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(3588,5): warning MSB3491: Could not write lines to file "obj\Debug\netstandard2.0\.NETStandard,Version=v2.0.AssemblyAttributes.cs". Access to the path 'D:\src\XXXn\obj\Debug\netstandard2.0\.NETStandard,Version=v2.0.AssemblyAttributes.cs' is denied.
When logs are set to verbose, the following is emitted (only including for net7.0 TFM):
> Target GenerateTargetFrameworkMonikerAttribute:
> Building target "GenerateTargetFrameworkMonikerAttribute" completely.
> Input file "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.targets" is newer than output file "obj\Debug\net7.0\.NETCoreApp,Version=v7.0.AssemblyAttributes.cs".
> Task "WriteLinesToFile"
> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(3588,5): warning MSB3491: Could not write lines to file "obj\Debug\net7.0\.NETCoreApp,Version=v7.0.AssemblyAttributes.cs". Access to the path 'D:\src\XXX\obj\Debug\net7.0\.NETCoreApp,Version=v7.0.AssemblyAttributes.cs' is denied.
> The previous error was converted to a warning because the task was called with ContinueOnError=true.
> Build continuing because "ContinueOnError" on the task "WriteLinesToFile" is set to "true".
> Done executing task "WriteLinesToFile" -- FAILED.
> Done building target "GenerateTargetFrameworkMonikerAttribute" in project "HatTrick.DbEx.CodeTemplating.csproj".
The warnings reference temporary files created by the build process prior to compilation.
Things I've tried to figure this out:
If I run dotnet build from the command line, it results in the same.
If I change branches/pull or clean/build/rebuild, the build fails - there are no error messages in the output, only the warnings above.
If I restart Visual Studio and rebuild, the build succeeds, but still has the warnings.
I've tried on another machine and it works as expected (no errors or warnings) - I cannot reproduce this issue on another machine.
I don't think it's a file/directory permission exception because I can rebuild and the build process outputs the assemblies to the bin and obj folders just fine.

Qt Visual Studio Tools moc and qrc don't respect pre-build events

I'd like to use a script to build translations (convert from .ts to .qm, using Qt's lrelease.exe) before compiling the resource file (QRC) where they are included. In this way I know they are always updated, not to mention to avoid including binary files in the repository.
I use Visual Studio and have installed the Qt Visual Studio Tools. Normally, I'd do this through a pre-build step in the project, but it is not being executed and the compilation of the QRC file always fails.
1>------ Build started: Project: MyApp, Configuration: Release Win32 ------
1>Rcc'ing MyApp.qrc...
1> RCC: Error in 'C:\src\MyApp\MyApp\MyApp.qrc': Cannot find file 'translations/myapp_en.qm'
1>MyApp.qrc : error 1: rcc (c:\Qt\qt_5_12_3\v141\Win32\bin\rcc.exe)
1>Done building project "MyApp.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 12 up-to-date, 1 skipped ==========
The script works correctly and it is called successfully either if placed as a post-build event or from command line.
#echo off
pushd "%1"
for %%F in (*.ts) do (
c:\Qt\qt_5_12_3\v141\Win32\bin\lrelease -compress %%F -qm %%~nF.qm
)
popd
exit /b 0
What I'm I doing wrong?
It happened that I was using the new Qt/MSBuild mode of Qt VS Tools. Internally it generates several hidden targets in the MSBuild workflow, which are executed before the pre-build events.
The solution was to use a custom build step instead, with some specific settings:
Execute before the QtRcc target (the one that actually compiles the resource file)
The Qt VS Tools parses QRC files to check if the resources have been modified, so it can skip compiling them. It is necessary to add the .qm translation files as output of the custom build step.
Similarly, to guarantee translations are always compiled, set dependencies of the custom build step to the .ts source files.

Xamarin Forms c# - java exited with code 1 in VS Studio for Windows

I am trying to compile an android app with XF. I am getting the infamous java.exe exited with code 1 error message. I have enabled proguard.
I have gotten the error just from enabling proguard.
The error only seems to happen in VS for Windows. I got a different error in VSMac, but don't have that right here in front of me.
Updating proguard from it's home on sourceforge doesn't seem to do anything for me.
I have put a new proguard.cfg file in my project and have set the build property to be a proguard configuration file.
I don't know what to do here. I'm looking for any suggestions.
TIA.
Update 1:
I didn't add the build output because I couldn't find a good exception in it. I just have the following that I can find in the build output.
I wish I could find the error easily. I had turned on the build output. the only exception i can find is listed below. I checked the targets file and the line reference is for the Proguard section.
1> at proguard.Initializer.execute(Initializer.java:485)
1> at proguard.ProGuard.initialize(ProGuard.java:271)
1> at proguard.ProGuard.execute(ProGuard.java:113)
1> at proguard.ProGuard.main(ProGuard.java:572)
1> Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2550,3):
Link to build output: https://www.dropbox.com/s/jl1o2hf7aeji243/BuildOutput.zip?dl=0

Execute bat file in the build event got the error "error MSB3073: The command "call "MyTest.bat" exited with code 1."

In our solution we have more than 150 projects, I need build one of project before others, but I did not want to set project reference or project dependencies for more than 100 projects one by one. This is a waste of time. So I ask following question before this one:
Set build order without using project reference
And as #Leo Liu suggested that I could use batch file to build the project first, it is should be a valid workaround. As optimization, I want set this bat file in the build event of that project so that I only need to build that project, do not need to manually run the bat file from outside.
However, when I build that project with below build event:
call "$(ProjectDir)\MyTest.bat"
I got this error:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\Microsoft.Common.CurrentVersion.targets(5074,5): error MSB3073: The command "call "C:\Users\Myname\Source\repos\MysolutionName\GenerateFile\MyTest.bat"" exited with code 1. [C:\Users\\Source\repos\MysolutionName\GenerateFile\GenerateFile.csproj]
Update:
The scripts in the bat file is:
#echo OFF
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat"
echo "Starting Build for all Projects with proposed changes"
MSBuild.exe "C:\Users\MyName\Source\repos\MySolutionName\MySolutionName.sln"
pause
echo "All builds completed."
Any suggestion? Thanks in advance.
Execute bat file in the build event got the error “error MSB3073: The command ”call “MyTest.bat” exited with code 1."
According to your question, I created a test sample and got more than 30 errors without any other detailed info:
error MSB3073: The command "call "D:\TestSample.bat"" exited with code 1.
Further study found the reason for those errors, that because you build the solution in the bat file, then you set this bat file in the build event of one project in the solution, which called in the bat file.
So an infinite loop will generated, that is the reason why we got more than 30 errors for one command line in the build event.
To resolve this issue, we should not build the specify project when we build the solution with bat file, so you could open Configuration Manager, uncheck the build checkbox for generate project:
With this setting, this project will be ignore when you build the solution with that bat file.

Running devenv.com displays a popup dialog and hangs TeamCity build

My end goal is to run a devenv.com command from a TeamCity build configuration but it's currently hanging when it reaches the deploy stage. If I run the same command from the command line on the build agent server I get a popup at the point when it reaches the deploy stage.
Should state that the solution is a mixture of VSeWSS and WSPBuilder projects for creating .wsp solution files for WSS 3.0.
The command is
"C:\Program Files (x86)\Microsoft Visual Studio
9.0\Common7\IDE\devenv.com" "C:\b\work\807e2e3b4b06ef27\mySolution.sln" /deploy Release /package
The dialog that gets displayed is:
If I hit OK in this dialog, I then get this one:
I assume it's hanging in the TeamCity build because the dialog is stopping the process. I was under the impression though that running "devenv.com" would prevent any UI elements from being shown.

Resources