I have a post build task that I run on my MVC 3 project, 'jake build', that combines a bunch of coffee script files and runs some tests using Phantom.js.
I don't expect appharbor to run this when I deploy, but it is trying to. It is of course failing because node, jake, and any number of other node modules are not installed. Is there a way to have this post build process run on my local machine when I build but have appharbor ignore it?
I figured this out using this questions: How to run Visual Studio post-build events for debug build only
You can do this in the ide:
if $(ConfigurationName) == Debug jake build
or this in the source of your project file:
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<PostBuildEvent>start gpedit</PostBuildEvent>
</PropertyGroup>
Related
I have complex Xamarin solution with android, ios and nestandard core project (defined via Microsoft.NET.Sdk) and few other csprojs with some logic (some are defined via Microsoft.NET.Sdk as netstandard2.0. others defined via MSBuild.Sdk.Extras for multitargeting the netstandard2.0, xamarin.ios10, monoandroid10.0 and have some platform specific code)
Local build on my macos with latest libraries is ok (both netcore 3 and 5, latest xamarin. tried on Rider and VS for mac).
ADO build succeed on windows-2019 agent using msbuild (just regular CI with codechecks etc)
ADO build on macos-10.15 agent (different jobs for ios and android packaging, using XamarinIos/XamarinAndroid tasks) fails with kind of strange behaviour:
i see a lot of namespace errors in droid/ios projects for platform-specific libraries from my solution.
i've made some investigations and found out that msbuild runs platform specific builds of csprojs first, copies the outputs, then runs the netstandard build for the same csprojs and replace files in output with netstandard versions. which, obviously, didn't have any line of platform specific code.
so, the question is wtf? how am i suppose to fix this?
what i tried:
replace Xamarin tasks with msbuild calls
change Xamarin SDK version to 16_12_3 and 16_12_0 (current is 16_12_2)
change .net version to 5 (current is 3.1.x) both ways - via global.json and installing v5 using the UseDotNet#2 task
core project was converted to multitarget
remove everything from sln and add every project from the scratch
also i thought that msbuild, maybe, trying to make a nupkg from my libraries so i tried this in build props:
<PropertyGroup>
<IsPackable>false</IsPackable>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
</PropertyGroup>
also i have this
<PropertyGroup Label="Multiplatform" Condition=" '$(TargetsToBuild)' != 'All' ">
<TargetFrameworks Condition=" '$(TargetsToBuild)' == 'Android' ">monoandroid10.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetsToBuild)' == 'iOS' ">xamarin.ios10</TargetFrameworks>
</PropertyGroup>
and multitarget projects has this
<PropertyGroup Label="Multiplatform">
<TargetFrameworks>netstandard2.0;xamarin.ios10;monoandroid10.0</TargetFrameworks>
</PropertyGroup>
of course i've tried to remove the tags above and build without them. no luck :(
So the answer is:
you should add csproj references to other projects in right order :/ order is matters for msbild
Background
I have an import process, which includes uploading a couple of files, which then go into an "Import" folder, the user then processes the files (get put into the database), which then get put into an "Archive" folder.
Problem
Running tests for this process, is where I'm encountering the problem.
The test import files for this are stored in a "Resources" (including Import and Archive) folder within the Tests project within the Visual Studio solution.
Current Solution: Attempt
A post-build event has been setup on the project to xcopy the "Resources" folder to the ${Outdir} - this works great in Visual Studio.
Problem
When I run Teamcity, the solution build - creates the folder (and subfolders) in /bin/Release/ rather than Teamcity's /out/ directory.
I'm sure I'm just not doing the copy in the correct way, there have been some suggestions of using MSBuild rather than xcopy, so could do with some help.
How do I setup Teamcity / my Solution to build to output these test files to the same place.
Using TeamCity
You can override the build output path by passing in the parameter to msbuild - this will override the project settings.
In the MsBuild / Visual Studio runner step, add this into the Command Line Parameters field
/p:OutputPath=out
The other alternative is to edit the project file in an editor and change the path there.
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>out\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
This will ensure that all files are output to a directory that is consistent whether you are building in Visual Studio or TeamCity
To get your test files into this directory, I would set the build action on them to Content and to copy if newer.
Hope this helps.
My objective is to have specific assembly per configuration. For now i am working on the debug configuration.
I have changed my Debug Configuration node in csproj xml file to the following.
<AssemblyName Condition=" '$(Configuration)' == 'CE_1' ">proj.CE_1</AssemblyName>
<StartAction Condition=" '$(Configuration)' == 'CE_1' ">proj.CE_1</StartAction>
<DeployDirSuffix>Proj</DeployDirSuffix>
In my Project > Properties > Debug the start Action is set to Start Project.
Why is VS08 still looking for Proj/CE.exe (the Assembly name of the project is CE) when i debug this project - when i clearly set it to proj.CE_1 as shown above.
The weird thing is if i just build the project or when Deploying finishes to a device, the exe in the debug folder or on the device is proj.CE_1.exe. The next step after deploying is running the exe and that is the part that is using the old assembly name..aka - The right assembly is being deployed but VS is trying to execute the old assembly name.
Also I am not sure what the StartAction value should be if thats the issue.
Thanks.
I have a solution with multiple projects. I am trying to use MSBUILD to automate the deployment. I have following configuration values for building
1. Debug
2. Release
3. Dev
For Some projects, I am using Release mode for DEV configuration. But while using DEV as configuration in MSBUILD command, it is throwing exception saying DEV configuration was not found.
Is there any way we can tell MSBUILD to use Release mode if DEV is not available for a project when DEV is used as configuration in MSBUILD?
Thanks
Ashwani
In your (presumably C#) project file, there is typically a line that looks like this:
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
For the projects that don't have a "Dev" configuration, you can get the behavior you want by adding another line, right before that one...
<Configuration Condition=" '$(Configuration)' == 'Dev' ">Release</Configuration>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
This way, when you build with "Dev" specified, these projects will build their Release configuration instead, which mimics the behavior of the solution's configuration manager (which I tend to think of as an abomination of a feature) directly in the project file itself, which is the right place to do it.
Another approach is to use the AdditionalProperties metadata on the item array you would be passing to the MSBuild task to get your projects built. You can specify--for the projects of interest--the following...
<SolutionItem Include="./PathTo/SomeProject.csproj">
<AdditionalProperties Condition="'$(Configuration)' == 'Dev'"
>Configuration=Release</AdditionalProperties>
</SolutionItem>
(Excerpted from the book "MSBuild Trickery" trick #80)
I don't think it can be done with a command argument to MSBuild.
What you could do is use the Configuration Manager for Visual Studio and for the solution configuration 'Dev' point the projects which don't have the 'Dev' configuration to Release.
Then you do a solution build for Dev configuration and some projects will build in release.
I migrated a Web Site project (with Web Deployment project) from VS2008 to VS2010. Now I can make "Build Deployment Package" for Web Deployment Project in VS2010 and it works great! But I can't find a way how to do the same via MSBuild.
I answer on my one question. So after a lot of googling and 2 days of investigation it finally works.
Brief how to:
I created Configuration = QA (based on Debug configuration) for Solution via Configuration Manager.
Important: I removed 'Platform' parameter for QA Configuration. I couldn't build package until I did it. (My dev computer is Win7-x64, and I'm not not sure would be this step necessary for x86. But my build server Win2008-x86 forks fine with this modification.) This is QA Configuration section from my .wdproj
<PropertyGroup Condition=" '$(Configuration)' == 'QA' ">
<DebugSymbols>True</DebugSymbols>
<OutputPath>QA\</OutputPath>
<EnableUpdateable>true</EnableUpdateable>
<UseMerge>true</UseMerge>
<SingleAssemblyName>
</SingleAssemblyName>
<UseWebConfigReplacement>false</UseWebConfigReplacement>
<DeleteAppDataFolder>true</DeleteAppDataFolder>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<ExcludeApp_Data>true</ExcludeApp_Data>
</PropertyGroup>
I build and package .wbproj file with the following command:
msbuild WebSite.Deploy.wdproj /t:Build;Package /p:Configuration=QA
For information: If you need you can use standard Web Publishing parameters (e.g. ExcludeApp_Data, DeployIisAppPath etc.) in the QA configuration section.
Try
MSBuild YourProject.csproj /T:Package
That should generate a deployment package. This page, How to: Use MSBuild to Create a Web Package might give a bit more information, but not much.