Quantcast
Channel: MSBuild forum
Viewing all 2763 articles
Browse latest View live

MSBUILD: Undefined preprocessor variable '$(var.ProjectName.OutDir)'.

$
0
0

Hello there,

I'm trying to build a WIX installer in MSBUILD but I'm getting the error described in the title.

Previously I tried TargetDir which worked fine locally in my machine but then it displayed the same error in the server/MSBUILD.

Any help is highly appreciated,

Javier Andres Caceres Alvis


/clr AND /rtc

$
0
0

In order to use:
using namespace System::ComponentModel;
using namespace System::Data;
using namespace System::Drawing;

I had to go to the project properties and turn on /clr (Common Language RunTime Support)

After that it gave me an error saying it was incomparable with /RTC1 so I was forced to change that setting to 'Default'

Now everything compiles fine, but the 'Visual Studio Express 2012' IDE does not underline anything (does not alert me of errors) which is annoying.

Does anything know of any work arounds? I am 100% there is a way  to resolve this because a few days ago I messed around with the project properties for a few hours and got this to work, but forgot to save the properties. Today I am unable to figure this out again..

Deploy code to iis using command line and ms build

$
0
0

Hi Friends,

I got requirement to build and deploy the code (Web Deploy) using msbuild command line.I could able to build it successfully.But I am unable to deploy to IIS .

if application is not created in IIS ,It need to create the application in IIS and deploy the code in respective drive.

please suggest me.

Thanks in advance

With Regards,

Datta.G

1. What’s the difference when compiling projects using Devenv, MSBuild and VCBuild?

MSBuild BuildInParallel, custom task spawning process that fails to run

$
0
0

I'm using the BuildInParallel attribute of the MSBuild task to run build projects in parallel. The root project is building four child projects. The child projects are using a custom MSBuild task which starts a new process using System.Diagnostics.Process. For some reason the spawned process fail to run properly when UseShellExecute is false. I've no idea why this is and I can't figure out what the error is - all that happens is the Process.ExitCode is 1, no exception..

Here's the custom MSBuild task:

using System;
using Microsoft.Build.Utilities;
using System.Diagnostics;

public class MSBuildProcessTask : Task
{
    public string Executable { get; set; }
    public string Arguments { get; set; }

    public override bool Execute()
    {
        using (var p = new Process())
        {
            try
            {
                p.StartInfo = new ProcessStartInfo(Executable, Arguments)
                                {
                                    UseShellExecute = false,
                                    //RedirectStandardOutput = true
                                };
                //p.OutputDataReceived += (o, e) =>
                //{
                //    if (e.Data != null)
                //    {
                //        Log.LogMessage(MessageImportance.Normal, e.Data);
                //    }
                //};
                p.Start();
                //p.BeginOutputReadLine();
                p.WaitForExit();
            }
            catch (Exception e)
            {
                throw; // for setting breakpoint
            }
            finally
            {
                if (p.ExitCode != 0)
                {
                    Log.LogError("Error.  Exit code: " + p.ExitCode);
                }
                p.Close();
            }
        }
        return true;
    }
}

And here's the root MSBuild project file (Test.proj, actually I'm only building two child project here but still get the error..):

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <UsingTask TaskName="MSBuildProcessTask" AssemblyFile="C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuildProcessTask\bin\Debug\MSBuildProcessTask.dll" />
    <Target Name="Default">
        <ItemGroup>
            <ProjectFiles Include="$(MSBuildProjectDirectory)\Test.1.proj" />
            <ProjectFiles Include="$(MSBuildProjectDirectory)\Test.2.proj" />
            <!--<ProjectFiles Include="$(MSBuildProjectDirectory)\Test.3.proj" />
            <ProjectFiles Include="$(MSBuildProjectDirectory)\Test.4.proj" />-->
        </ItemGroup>
            <MSBuild BuildInParallel="true" Projects="@(ProjectFiles)" />
    </Target>
</Project>

And here's an example of the child project files (Test.1.proj):

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <UsingTask TaskName="MSBuildProcessTask" AssemblyFile="C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuildProcessTask\bin\Debug\MSBuildProcessTask.dll" />
    <Target Name="Default">
        <Message Text="Hello" />
        <MSBuildProcessTask Executable="sqlcmd" Arguments="-S .\SQLEXPRESS -Q &quot;SELECT @@VERSION&quot;" />
    </Target>
</Project>

My command line is: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /m /nr:false C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuild ProcessTask\Test.proj

And here's a sample output:

C:\Users\Tom>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /m /nr:false C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuildPr
ocessTask\Test.proj
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.235]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 16/08/2011 22:22:06.
     1>Project "C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuildProcessTask\Test.proj" on node 1 (default targets).
     1>Project "C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuildProcessTask\Test.proj" (1) is building "C:\Users\Tom\Sandbox\reposito
       ry_trunk\MSBuildProcessTask\MSBuildProcessTask\Test.1.proj" (2) on node 1 (default targets).
     2>Default:
         Hello
     1>Project "C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuildProcessTask\Test.proj" (1) is building "C:\Users\Tom\Sandbox\reposito
       ry_trunk\MSBuildProcessTask\MSBuildProcessTask\Test.2.proj" (3) on node 2 (default targets).



------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------

Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)
        Mar 29 2009 10:11:52
        Copyright (c) 1988-2008 Microsoft Corporation
        Express Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)


(1 rows affected)
     3>Default:
         Hello
     2>Done Building Project "C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuildProcessTask\Test.1.proj" (default targets).
     3>C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuildProcessTask\Test.2.proj(6,3): error : Error.  Exit code: 1
     3>Done Building Project "C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuildProcessTask\Test.2.proj" (default targets).
     1>Done Building Project "C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuildProcessTask\Test.proj" (default targets).

Build succeeded.

       "C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuildProcessTask\Test.proj" (default target) (1) ->
       "C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuildProcessTask\Test.2.proj" (default target) (3) ->
       (Default target) ->
         C:\Users\Tom\Sandbox\repository_trunk\MSBuildProcessTask\MSBuildProcessTask\Test.2.proj(6,3): error : Error.  Exit code: 1

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.23

C:\Users\Tom>

As you can see we only get output from one of the SQLCMD commands. The problem is that the new process doesn't always seem to run, and doesn't produce any error message (only ExitCode 1). 

MSBuild Customization issue

$
0
0

Hi Friends,

I got requirment to build and deploy the project from commandline. I am using MSBuild to build the project.I am using the MSDeploy to deploy the project.

1) When I build Package zip file got created with respective manifest file. I am able to deploy the package using MSDeploy with Auto destination property.Its creating project in IIS and physical directory is created in WWWroot.

My Issue: I need To create project in IIS and Physical folder should be custom location.But when I am trying to use 

C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild D:\ProHub-BNSF\branches\ProHub\ProHub\ProHub.csproj "/p:Platform=AnyCPU;Configuration=Release;PublishDestination=D:\ProHubDeploy

Error: C:\msdeploy.exe -verb:sync -source:package=D:\ProHub-BNSF\branches\ProHub\ProHub\obj\Debug\Package\ProHub.zip -dest:contentpath=D:\ProHubDeploy

Package is coming with Manifest file.But When I manually zip the files in PackageTmp  folder. I am able to deploy in my custom location.I need to configure in IIS With Custom Physical path


Thanks in advance

With Regards,

Datta.G

Why is multi processor build not really using all available CPU?

$
0
0

Hello,

I have a project with around 260 translation units (fancy for source files) and a 32 effective CPU system (2 CPU * 8 cores 2 * for Hyper threaded) and I of course use the /MP... I have plenty of RAM and everything is in cache...

When I compile (an I am talking only about the 'core' C++ files compilations here, not pre-build, PCH generation (why can that not be done in parallel?), or linking), it never uses all available CPU power...

It seems that the system should send n sources code for compilation, one per core, and send a new one as soon as a source is translated...

However, it looks like what is really happening is that it sends 32 files for compilation, waits for all compilation to complete before sending 32 new files...

Since my files are of very different sizes (especially, I have a couple of very large data files), it means that 20 or so of the 32 files started at the same time finish really fast.. and these 20 core do nothing while the last 21 files complete...

Is there any way to improve on this?

Cyrille

String property function

$
0
0

Hi,

This script gives for me an unexpected result. Anyone that can explain what is going on and what change I can do to get the expected result. Originally I used "Replace" instead of "Trim", but with same result.

Why is not "SolutionFileItemReplFullPath" batched the same way as SolutionFileItemOrigFullPath ?

BR Ulf

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">

  <Target Name="TestReplace">
    <ItemGroup>
      <SolutionFileItemOrig Include="$(SolutionFileName)"/>
      <SolutionFileItemRepl Include="$(SolutionFileName.Trim())"/>
    </ItemGroup>
    
    <Message Text="TRACE : SolutionFileItemOrig: @(SolutionFileItemOrig)"/>
    <Message Text="TRACE : SolutionFileItemOrigFullPath: %(SolutionFileItemOrig.FullPath)"/>
    
    <Message Text="TRACE : SolutionFileItemRepl: @(SolutionFileItemRepl)"/>
    <Message Text="TRACE : SolutionFileItemReplFullPath: %(SolutionFileItemRepl.FullPath)"/>
  </Target>
</Project>

msbuild /p:SolutionFileName="3.sln;4.sln" TestPropertyFuction.proj

Build started 2014-12-01 11:44:14.
Project "C:\MsBuildTest\TestPropertyFuction.proj" on node 1 (default targets).
TestReplace:
  TRACE : SolutionFileItemOrig: 3.sln;4.sln
  TRACE : SolutionFileItemOrigFullPath: C:\MsBuildTest\3.sln
  TRACE : SolutionFileItemOrigFullPath: C:\MsBuildTest\4.sln
  TRACE : SolutionFileItemRepl: 3.sln;4.sln
  TRACE : SolutionFileItemReplFullPath: C:\MsBuildTest\3.sln;4.sln
Done Building Project "C:\MsBuildTest\TestPropertyFuction.proj" (default targets).


Build succeeded.


Customize location of MSBuild during installation of Visual Studio 2013

$
0
0

Hi - we install Visual Studio 2013 with a complete silent installation:

vs_premium.exe /full /CustomInstallPath "C:\Dev\Microsoft Visual Studio 12.0" /passive /norestart /log "%TEMP%\vs2013_install_log.txt"

However, i also want to customize the location of MSBuild during the installation to the same "C:\Dev" path.  (C:\Dev is treated special in our network wrt virus scanning rules).

Is this possible during the installation?  Or is MSBuild always going to be installed to the default location in "Program Files (x86)"??

Also, now that we have deployed VS2013 to our 100+ engineers, is it possible to move MSBuild to C:\Dev  (maybe uninstall/reinstall just that portion?)

Thanks for any assistance...

Download Hotfix Rollup 2828841

$
0
0

I have been reporting on Issue 2 of this hotfix since October of 2012 and would like to download this as soon as possible.  It appears that I need to open a support ticket however. 

Is there an alternative?

MSBuild - CodeAnalysis fails succeeding projects

$
0
0

Hello specialists,

hope someone has an idea about the following issue.

We run MSBuild (VS2013) on a proj file that again runs msbuild on up to 1000 single projects.
Everything runs fine without CodeAnalysis.

Now we additionally run CodeAnalysis (<RunCodeAnalysis>true</RunCodeAnalysis>) with the option "ContinueOnError = True" on each single project.
And then an error is detected in a single project...(Code Analysis Complete -- 1 error(s), 0 warning(s))
As expected the build will proceed - BUT succeeding projects that apparently use the failed project's assemblies as references will all fail with a "missing assembly error".
However, the assemblies from the CodeAnalysis-failed project is physically existent. It is even copied to its final destination by a post build step....

Can someone explain this strange behavior? It seems like MSBuild is just ignoring the assembly from the failed project or is tagging it as "absent".

Our goal is just to detect all CodeAnalysis errors on all of our projects. How to achieve this?

Error in VS Build: Files has invalid value "

$
0
0

I am having the following errors in my VS build

 

Error 2 Files has invalid value "<<<<<<< .mine". Illegal characters in path.

 

The only info coming out is the Project its associated with, however there is no file with this name.  Any help would be appreciated.  It is a working copy of a subversion controlled project (client is tortoise svn).  But I can't see how this would be cause the problem with the build process?

 

Kind Regards,

Luke Cloudsdale

Microsoft.CSharp.targets(160,9): error MSB6006: "Csc.exe" exited with code -1073741629

$
0
0

Hi,

When we run our build we get the following error message:

C:\windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.CSharp.targets(160,9): error MSB6006: "Csc.exe" exited with code -1073741629.

The build fails and we have to restart it.

The problem is not happening for the same assembly. It doesn't come every time you run the build. It may fail a number of times in a row and then at the next try the build is successful.

The following is the detailed output from the build log:

       "c:\temp\I-COMPL\I-COMPL.sln" (Build target) (1) ->
       "c:\temp\I-COMPL\OM\Common\ErrorProvider\IntegrationTest\IMS.OM.Common.ErrorProvider.IntegrationTest.csproj" (default target) (982) ->
       "c:\temp\I-COMPL\OM\Common\ErrorProvider\IntegrationTest\pnhq31tn.tmp_proj" (_CompileTemporaryAssembly target) (1452) ->
       (CoreCompile target) ->
         C:\windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.CSharp.targets(160,9): error MSB6006: "Csc.exe" exited with code -1073741629. [c:\temp\I-COMPL\OM\Common\ErrorProvider\IntegrationTest\pnhq31tn.tmp_proj]

Can you please help with what this error mean? And how we can prevent this for failing our builds in this stochastic manner?

Thanks!

Christian

about visual studio 2015 run environment

$
0
0

I want to know the run environment about Visual Studio 2015

my operating system is windows 7,can i use vs 2015 ??

Create project programmatically with MSBuild 4.0

$
0
0

Hi,

It used to be pretty easy creating project files with MSBuild 3.5, e.g.

 

using Microsoft.Build.BuildEngine;
using System.Runtime.InteropServices;

Microsoft.Build.BuildEngine.Project testProj = new Microsoft.Build.BuildEngine.Project(new Engine(@"C:\Windows\Microsoft.Net\Framework\v3.5\MSBuild.exe"));
Target buildTarget = testProj.Targets.AddNewTarget("BuildProjects");
BuildTask msBuildTask = buildTarget.AddNewTask("MSBuild");
testProj.Save(@"C:\testProj.proj");

Now that Microsoft.Build.BuildEngine namespace is deprecated I can't figure out how to proceed. I can create an empty project as follows:

using Microsoft.Build.Evaluation;
using Microsoft.Build.Construction;
using Microsoft.Build.Execution;

Project testProj = new Project();

// How to add targets and tasks???

testProj.Save(@"C:\testProj.proj");

 

But I don't know how to set additional project elements, custom targets, etc.. Can you provide any suggestions, pointers, resources with code samples? There doesn't seem to be any code samples at all on MSDN.

 

Thanks,

Vladimir Nestoyanov

 


Msbuild - Precompiled aspx pages not generating in output build

$
0
0

Hello,

i tried the following build script in a seperate proj file for a web application but it does not generate me the precompiled pages as a whole which i can use for hosting.

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup>
<ProjectPath>C:\My Experiments\CKEditor\CKEditor.Prototype\CKEditor.Prototype.sln</ProjectPath>
    <BuildOutputPath>C:\temp\Out\</BuildOutputPath>
  </PropertyGroup>
  
  <Target Name="Test" >
    <MSBuild Projects="$(ProjectPath)" Properties="Configuration=Release;OutputPath=$(BuildOutputPath);"></MSBuild>
  </Target>
  <Import Project="MSBuild.ExtensionPack.tasks"/>
</Project>

it generates only dll and not the pages and images which i have referenced in the csproj.

Note: I also tried by importing .csproj in the property group but still i do not get my desired output of precompiled aspx files.

Load csproj file using Microsoft.Build.Evaluation

$
0
0
I have a single csproj file in resources of Unit Test project for *VS 2012*.

I want use `Microsoft.Build.Evaluation` for modify csproj (custom nodes: add nodes, delete nodes, modify nodes).

I use `GetLoadedProjects` but I get 0 value for `Count` property.
        [TestMethod]        [DeploymentItem(@"SW1.csproj")]        public void Csproj_is_ok()        {            var csprojPath = @"SW1.csproj";            Assert.IsTrue(File.Exists(csprojPath));            var collection = new ProjectCollection();            collection.DefaultToolsVersion = "4.0";            var project = collection.LoadProject(csprojPath);            var num1 = Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.GetLoadedProjects(csprojPath).Count;            var num2 = Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.GetLoadedProjects(project.FullPath).Count;            Assert.AreNotEqual(0, num1 + num2);            string szItemPath = "...";            Microsoft.Build.Evaluation.ProjectItem oItem = projectBuild.Items.Where(item => item.EvaluatedInclude.EndsWith(Path.GetFileName(szItemPath))).Single();            Assert.IsTrue(oItem.HasMetadata("MfaBranched"));            oItem.SetMetadataValue("MfaBranched", Path.GetFileNameWithoutExtension(szItemPath) + "_" + idBranch + Path.GetExtension(szItemPath));            projectBuild.ReevaluateIfNecessary();       }



Any suggestions?

www.kiquenet.com/profesional


Diagnostics on Azure VM

$
0
0

I have created couple of VMs in Azure but I don't see them in Visual Studio 2013. Is there specific version of Studio required. 


Possible to have a dynamic condition on Import or PropertyGroup?

$
0
0
I'm trying to implement the strategy outlined here: http://social.msdn.microsoft.com/forums/en-US/tfsbuild/thread/85710d6d-38e6-492f-8ba1-991926a03368/

However, I need to take it a step further.  We have multiple branches, so there are multiple build definitions for each build "type" (NightlyBuild and CheckInTest, to borrow his examples).  They already follow a regular naming convention, so I thought it would be a simple matter of changing the Import condition to a dynamically calculated variable:

<!-- import build-specific configurations -->
  <Target Name="BeforeEndToEndIteration">
    <RegexReplace Input="$(BuildDefinition)" Expression=".*\s-\s" Replacement="">
      <Output TaskParameter="Output" PropertyName="BuildType" />
    </RegexReplace>
  </Target>
  <Import Condition="$(BuildType)==full" Project="Full.targets" />
  <Import Condition="$(BuildType)==quick" Project="Quick.targets" />
  <Target Name="AfterEndToEndIteration">
    <Message Text="TestFlag=$(TestFlag)" />
  </Target>

$(BuildDefinition) is of the form "Main - full" or "Main - quick" or "Production - full" etc etc., passed by the Team Build agent onto the msbuild command line
BeforeEndToEndIteration is the first user-overridable target that runs.

Of course, this does not work because Import is evaluated before any targets run.  Unfortunately msbuild won't let me stick the Import element inside the target, nor stick the Regex task in the main Project block.

Is there any way to accomplish what I'm after?  The *.targets files are not too long, so I'd settle for conditional PropertyGroups that jammed all the customizations into one file if necessary, but from what I can tell PropertyGroup suffers the same limitations. 

[IMO, the best improvement would be if msbuild allowed user-defined comparison operators.  Then I could use an operator like "endswith" or "regexmatch".]

Batching

$
0
0

Hello,

I have a need to do type of batching that I've not been able to find.  I'd like to loop (batch)
across a set of name/value pairs and only act on them after all of them have been evaluated.
Plus, the number of pairs is not known until execution time.

Here is an example of the name/value pairs, showing 3 pairs.  But there could be any number of pairs.
    <ItemGroup>
      <Property Include="1">
        <Name>mary</Name>
        <Value>1</Value>
      </Property>
      <Property Include="2">
        <Name>fred</Name>
        <Value>2</Value>
      </Property>
      <Property Include="3">
        <Name>bill</Name>
        <Value>3</Value>
      </Property>
 ... there is an unknown number of these <Property> inputs
    </ItemGroup>


I would like to batch across the above ItemGroup and create a result like the following:
   Command Name1=value1 Name2=Value2 Name3=Value3 ... NameX=ValueX

The results I'm getting are
   Command Name1=value1
   Command Name2=Value2
   Command Name3=Value3

All of the batching options I have seen involve essentially an execution at the end of each
batch loop.  What I need is to accumulate the batch results and execute only once, after the final
batch evaluation.

Is this possible?

Thanks


Curt Zarger curtis.zarger@asmr.com

Viewing all 2763 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>