msbuild

Using robocopy with Visual Studio 2010 Post-build and Pre-build events

。_饼干妹妹 提交于 2019-12-20 11:03:11
问题 Robocopy outputs 1 upon success, unlike most programs that exit with 0 on success. Visual Studio (and MSBUILD) interprets exit code of 1 as an error. How can Robocopy be used in Visual Studio post- and pre-build events such that its failure and success are correctly identified by the build environment? Note: this is more or less a repost of this post. 回答1: MSBuild extensionpack contains a Robocopy task that you can use in your build process. Can this be a solution for you instead of VS pre

Antlr4 C# targets and output path of generated files

ⅰ亾dé卋堺 提交于 2019-12-20 10:58:37
问题 I have a C# solution with an Antlr3 grammar file, and I'm trying to upgrade to Anltr4. It turns out the grammar was the easy part (it became better, and one third the size!). Generating the parser turned out to be the tricky part. In the old solution I merely ran AntlrWorks to update the lexer and parser .cs files when the grammar file changed. The lexer and parser were included directly in the same project as the grammar so the framework around the parser could make use of them directly.

How to “get rid of” $(SolutionDir) when building Visual Studio project from outside Visual Studio

你。 提交于 2019-12-20 10:39:47
问题 I want to build a .vcxproj via MSBuild from outside Visual Studio. The problem is that there are many occurrences of $(SolutionDir) inside the .vcxproj file which apparently only get set correctly when the solution is loaded. When I replace $(SolutionDir) with the actual absolute path, it works. But other people on other machines are working with the same project file, so this is not a solution. Is there a solution or hack to solve this problem? 回答1: You can set the variable by passing

Targeting both .NET 3.5 and Silverlight

落花浮王杯 提交于 2019-12-20 10:37:17
问题 Let's imagine I already have a project building .NET 3.5 assembly. Now I want to build this assembly for Silverlight, and moreover, maintain its Silverlight version with minimal efforts further. What is not acceptable: Creating separate project for Silverlight build What is acceptable: Adding custom directives allowing me to target either Silverlight or .NET dependently on e.g. MSBuild properties. Adding special build configurations for Silverlight Adding #ifdef Silverlight / #endif sections

PrecompileBeforePublish using Msbuild

南笙酒味 提交于 2019-12-20 10:35:17
问题 We are using Windows Azure to host our application on a Cloud Service and use Powershell to build and package the website using msbuild . On releasing our first response time is very slow so naturally we'd need to precompile the application. There's plenty of documentation for Precompiling using the aspnet_compiler, however I cannot find any official documentation on using: msbuild Web.sln /p:PrecompileBeforePublish=true A Google search targeted at MSDN gives me nothing whilst usually MSDN is

MSBuild - how to copy files that may or may not exist?

余生长醉 提交于 2019-12-20 10:34:24
问题 I have a situation where I need to copy a few specific files in a MSBuild script, but they may or may not exist. If they don't exist it's fine, I don't need them then. But the standard <copy> task throws an error if it cannot find each and every item in the list... 回答1: Use the Exists condition on Copy task. <CreateItem Include="*.xml"> <Output ItemName="ItemsThatNeedToBeCopied" TaskParameter="Include"/> </CreateItem> <Copy SourceFiles="@(ItemsThatNeedToBeCopied)" DestinationFolder="$

MSbuild Copy whole folder

╄→尐↘猪︶ㄣ 提交于 2019-12-20 10:18:10
问题 trying to copy a whole folder, but when i do this: <Copy SourceFiles="$(TargetDir)\*.*" DestinationFolder="$(BuildOutput)\SomeDir" /> the copy attempts to do this: copy c:\source\*.* c:\destination\SomeDir\*.* and fails with "illegal characters" 回答1: Specify your ItemGroup for SourceFiles explicitly. <ItemGroup> <_CopyItems Include="$(TargetDir)\*.*" /> </ItemGroup> <Copy SourceFiles="@(_CopyItems)" DestinationFolder="$(BuildOutput)\SomeDir" /> Note that _CopyItems is an item type, so it's

Integrating MSBuild into Visual Studio

爱⌒轻易说出口 提交于 2019-12-20 09:49:26
问题 I'm a solo developer running Visual Studio 2008 and looking into MSBuild to improve my build process. Almost all of the tutorials I've found so far have plenty of information about writing a build file. However I'm having a lot of trouble finding out how to integrate MSBuild into Visual Studio. Maybe MSBuild is only used with something like CruiseControl but that's overkill for me as a single developer. Where should the build file live in a Visual Studio project and how can I run it from

Project fails to load due to missing SqlServer.targets file after upgrading to Visual Studio 2013

自闭症网瘾萝莉.ら 提交于 2019-12-20 09:48:25
问题 Having upgraded to Visual Studio 2013, I have found that an old SQL project fails to load when I attempt to open a solution. The error displayed is: The imported project "C:\Program Files (x86)\MSBuild\12.0\bin\SqlServer.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. C:\Some\Path\To\Project\Database.sqlproj In my .sqlproj file I have the line <Import Project="$(MSBuildToolsPath)\SqlServer.targets" /> which in Visual Studio 2012

Make sure all *.cshtml files are set to be “Content” for Build Action

倖福魔咒の 提交于 2019-12-20 09:47:18
问题 A few times when I copy-paste *.cshtml files, Visual Studio for some reason sets Build Action on these files to be "None": This is impossible to detect when you work locally, because the files are present. But when you deploy through WebDeploy, files marked as "None" on Build Action are not packaged. As a result I get non-working application on the server. Question: is there a way to automatically detect such occurrences and prevent? 回答1: You could extend the .csproj with a small snippet that