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

How to force MsBuild to use existed dll?

$
0
0

How to force MsBuild to use existed dll?

I have folloving (simplified) definition in csproj file:

<Choose><When Condition=" '$(CCNetBuildId)' == '' AND '$(BatchBuild)' == '' "><ItemGroup><ProjectReference Include="..\GPS.Order.Factory\GPS.Order.Factory.csproj"><Project>{f3cd6b63-0312-4708-9c99-18232a20d21e}</Project><Name>GPS.Order.Factory</Name></ProjectReference></ItemGroup></When><When Condition=" '$(BatchBuild)' == 'true' "><ItemGroup><Reference Include="GPS.Order.Factory"><SpecificVersion>False</SpecificVersion><HintPath>GPS.Order.Factory.dll</HintPath><Private>False</Private></Reference>			</ItemGroup></When><Otherwise><ItemGroup><Reference Include="GPS.Order.Factory" /></ItemGroup></Otherwise></Choose>

Idea was - when I use a standard Studio build (not CruiseControl or my own batch file) will be compiled 

GPS.Order.Factory.csproj

if I use batch build - will be used dll in working folder.

In any other case (CruiseControl build) will be used any suitable (most likely - from working folder) instance of dll.

If something goes wrong - an error report expected.

But behavioure of MsBuild are different from expected.

On batch and CC builds MsBuild picked up DLL from OBJ folder of Gps.Order.Factory.csproj. Usually there are wrong DLL.

How do I suppress picking up wrong DLL?

I rememeber that I already do ask something similar when Studio 2015 was released and problem was confirmed.

But looks like the problem remain on place.


Sincerely, Highly skilled coding monkey.


How to resolve NuGet package local path

$
0
0

   Actually the main question is not that straightforward. The problem is that I need to include multiple versions of a NuGet package to a project. As I understood from searching for an answer on the internet the only option is to add App.config with the following lines

<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="Deep" culture="neutral" publicKeyToken="f694e838567cfe72" /><codeBase version="1.0.0.0" href="Deep-1.0.0.0.dll" /><codeBase version="2.0.0.0" href="Deep.dll" /><bindingRedirect oldVersion="1.0.0.0" newVersion="1.0.0.0" /><bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" /><bindingRedirect oldVersion="2.0.0.0" newVersion="2.0.0.0" /></dependentAssembly></assemblyBinding></runtime>

   Thus, I instruct the framework to load Deep-1.0.0.0.dll version when the code calls that particular assembly version. To make it work on the step of building the project I created an msbuild task. First of all I specify locations of assemblies I want to add to the project target directory, then the task goes over those assemblies, extracts their version numbers, adds them as -Major.Minor.0.0 to the file name, and copies the assemblies to the project target directory. Along with that it makes sure aforementioned configuration is added to the App.config.

   Now, I would like to do something similar for NuGet packages and the main problem is to find the right assembly in the NuGet assembly cache. For example if the NuGet assembly is referenced like

<ItemGroup><PackageReference Include="log4net"><Version>2.0.8</Version></PackageReference></ItemGroup>

   How do I find that assembly on the hard drive? I found it manually. It's at C:\Users\{UserName}\.nuget\packages\log4net\2.0.8\lib\net45-full. How can I find it while building the project? Is there a task or target I can call for that? Is it possible to find parts of this path somehow? Where to get the base path (C:\Users\{UserName}\.nuget\packages) from? How to figure out what should be the last part of the path which in this case is "net45-full"?

   Please, let me know if I'm complete on the wrong path and there is an easy way to include multiple versions of the same assembly to a project.

Thank you


Alex

How to install VS

$
0
0

Hello ,

We have a SQL Server 14.0.3238.1 installed on our server , we do not have a Visual Studio SSDT installed to create packages. Can anyone suggest what version of VS DDT should we install and if there is a link for installation. 

Thanks

The “CL” task failed unexpectedly in vs2017

$
0
0

I've got into trouble when I try to build a new C++ Project. The INFO like this. 

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018: The "CL" task failed unexpectedly.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018: System.TypeInitializationException: The type initializer for 'Microsoft.Build.Utilities.FileTracker' threw an exception. ---> System.UnauthorizedAccessException: Access denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.Shared.NativeMethodsShared.ThrowExceptionForErrorCode(Int32 errorCode)
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.Shared.NativeMethodsShared.GetLongFilePath(String path)
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.Utilities.FileTracker..cctor()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    --- End of inner exception stack trace ---
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.CPPTasks.CL.ComputeOutOfDateSources()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.CPPTasks.TrackedVCToolTask.SkipTaskExecution()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.Utilities.ToolTask.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.CPPTasks.TrackedVCToolTask.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

I really did nothing to my project configurations, and this is the C++ program I tried to build.

#include "stdafx.h"


int main()
{
    return 0;
}

I've got my Visual Studio 2017 reinstalled, but it seems to be useless

Error while compiling QT program in Visual Studio 2015 com edn.

$
0
0

I get the following error:

1>------ Build started: Project: analogclock, Configuration: Debug Win32 ------
1>  Generate moc_predefs.h
1>  Reading Qt configuration (C:\Qt\Qt5.8.0\5.8\msvc2015\bin\qmake.exe)
1>C:\Users\Dan\AppData\Local\QtMsBuild\qt_vars.targets(246,5): error : The source file for this compilation can be found at: "C:\Users\Dan\AppData\Local\Temp\a7b97cf6-8bae-46c1-a641-e713095be07e.txt"
1>C:\Users\Dan\AppData\Local\QtMsBuild\qt_vars.targets(246,5): error MSB3758: An error has occurred during compilation. c:\Users\Dan\AppData\Local\Temp\zfktvjfl.0.cs(88,26) : error CS1061: 'System.Collections.Generic.IEnumerable<string>' does not contain a definition for 'ToHashSet' and no extension method 'ToHashSet' accepting a first argument of type 'System.Collections.Generic.IEnumerable<string>' could be found (are you missing a using directive or an assembly reference?)
1>C:\Users\Dan\AppData\Local\QtMsBuild\qt_vars.targets(246,5): error MSB4036: The "GetVarsFromMakefile" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Program Files\MSBuild\14.0\bin" directory.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Please give me solution to this problem

MSB401

$
0
0
严重性代码 说明项目文件禁止显示状态禁止显示状态
错误MSB4018 “CL”任务意外失败。
System.TypeInitializationException: “Microsoft.Build.Utilities.FileTracker”的类型初始值设定项引发异常。 ---> System.UnauthorizedAccessException: 拒绝访问。 (异常来自 HRESULT:0x80070005 (E_ACCESSDENIED))
   在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   在 Microsoft.Build.Shared.NativeMethodsShared.ThrowExceptionForErrorCode(Int32 errorCode)
   在 Microsoft.Build.Shared.NativeMethodsShared.GetLongFilePath(String path)
   在 Microsoft.Build.Utilities.FileTracker..cctor()
   --- 内部异常堆栈跟踪的结尾 ---
   在 Microsoft.Build.Utilities.FileTracker.FormatRootingMarker(ITaskItem[] sources)
   在 Microsoft.Build.CPPTasks.CL.ComputeOutOfDateSources()
   在 Microsoft.Build.CPPTasks.TrackedVCToolTask.SkipTaskExecution()
   在 Microsoft.Build.Utilities.ToolTask.Execute()
   在 Microsoft.Build.CPPTasks.VCToolTask.Execute()
   在 Microsoft.Build.CPPTasks.TrackedVCToolTask.Execute()
   在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   在 Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()ConsoleApplication1C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets487

Cordova Universal Windows 10 App with localStorage

$
0
0

I do a Windows Universal 10 App with Cordova Tools in Visual STudio 2017 when i run the app i use localStorage.setItem / getItem

It works. but when i look in the C:\Users\usr\AppData\Local\Packages\com.edis.app_

Folder there is my Database which i also use .

I want to access the LocalStorage with a Viewer like the SQL lite Browser it should be also a file which i can browse but i cannot find it is it somewhere defined in the config where the location of the local Storage is?

Associating Build Number with TFS Work Items after build using vNext

$
0
0

Hi Team,

We have a requirement of associating work items with TFS Builds. Generally, this is possible (or we can say 'natural') while using XAML Build Templates in TFS (via Integration Build field of WorkItem. In the below screenshot it was mentioned as 'Integrated In'). We are currently trying to migrate from XAML Build Templates to vNext version of VSTFS 2015 and further to integrate with Octopus Deploy for CI/CD practices.


We are now half the way in the migration because we are stuck up making this vNext templates to associate TFS WorkItems with their Build numbers. Without doing this step, if we complete this migration, it will be difficult to get associated build numbers for each Work Items delivered in that build.

When we searched MSDN blogs, we got a post (link given below) similar to our requirement but I tried that and ended up with no luck. Search blogs with the tag - 'build-association-with-work-items-in-vnext'

So, please suggest the ways which can resolve our requirement.

Thank you,

Jayganesh Sambath


SolutionBuild.BuildProject hangs in VS2015

$
0
0
I am using SolutionBuild.BuildProject interface mentioned in below documentation link.
https://docs.microsoft.com/en-us/dotnet/api/envdte.solutionbuild.buildproject?view=visualstudiosdk-2015

Issue: When the execution operation goes into building a project through the above Interface, it goes into hangs state.
Could anyone please help to resolve the issue?

Thanks in Advance,
Sagar

Assembly 'MyDll.dll' must be strong signed in order to be marked as a prerequisite.

$
0
0

Hello Folks,

Another problem in MsBuild and MyApp.csproj file.

MyApp.csproj fragment:

<Choose><When Condition=" '$(MyFalseCondition)' == 'True' "> <!-- false condition!!! --><ItemGroup><ProjectReference Include="MyDll.csproj"><Project>{16263b86-4c23-48f3-a174-1b6d8cf0c391}</Project><Name>MyDll</Name><Private>False</Private> <!-- still affect deployment --></ProjectReference></ItemGroup></When><When Condition=" '$(MyTrueCondition)' == 'True' "><ItemGroup><Reference Include="MyDll"><SpecificVersion>False</SpecificVersion><HintPath>MyDll.dll</HintPath><Private>False</Private></Reference></ItemGroup></When></Choose>	


MsBuild 4.0 (from Framework folder) runs with params:

MsBuid.exe /p:MyFalseCondition=False;MyTrueCondition=True /t:Publish MyApp.csproj

Build not failed - MyDll.dll sucseffully build or are available in WorkingFolder, MyApp.csproj also build withot errors.

But on deployment MyDll.dll are marked as Prerequisite(Auto) instead of expected Include(Auto) and couse an error about signing.

As far as I known this are coused by <Private>False</Private>, but from <When Condition=" '$(MyFalseCondition)' == 'True' "> branch.

The same <Private>False</Private> in "True" branch should not couse such problem. 

Any idea about how to suppress picking up wrong elments on deployment? 

Used on the XP Mode VM with host system Win 7 Pro SP 1, installed Framework 4.0 and Studio 2010 Ent. 


Sincerely, Highly skilled coding monkey.

VS2017 Build Error The process cannot access the file

$
0
0

Hello,

I am running VS2017 version 15.3.3.  I just updated it yesterday in an attempt to resolve this issue.  When I attempt to build a C# WPF project for a second time, I get a build error telling me the .EXE file is in use by another process.  Closing the solution and reopening allows me to build the project.  This is very annoying and unproductive.  

This only occurs after I edit and save the MainWindow.xaml file.  I have also tried closing the xaml file before attempting the second build without any success.  

Visual Studio C++, in the pre-build event is there a way to get the list of files being compiled?

$
0
0

In the Pre-build event I'd like the list of files visual studio will compile. I'd like to run scripts just on those files. Is there a way to do this?  I don't want to check every file in the project every time I compile to see if the script needs to run on them.  I just want to run the script on the files that have changed/being compiled. Ideally I wouldn't have to detect myself which files have changed (by looking at timestamps or keeping track of a file hash).

In Visual Studio C++, the Prebuild event seems to go *after* project dependencies. Is there a way to make it go before?

$
0
0

I have a solution with 2 projects.  Let's say Project A and Project B.  Project B depends on Project A.  Project A has a pre build event set.  The build order ends up being Project B, the prebuild event, then Project A.  I would prefer it to be: prebuild event, Project B, then Project A.  Any way of doing this?

MSBuild 16/2019 version offline installer

$
0
0

Hi Team,

We need to install MSBbuild 16 version in our server, but it doesn't have internet enabled.

I have tried to install it using offline installer which is provided in official website, but it still asking for internet.

Please support on this, how it could be resolved?.

Thanks,

Getting csproj files info from a solution file

$
0
0

Is there any way we can get the csproj files being referred in a solution file? My build script only refers to solution file but I also need csproj files information.


How to restart Explorer as a pre-build event in Visual Studio

$
0
0
I'd like to restart Explorer when building my DLL in Visual Studio. I've tried adding taskkill /f /IM explorer.exe and start explorer as pre-build events in the project configuration. When I then build my project, Explorer will in fact be terminated, but it will not be successfully restarted. The taskbar will remain missing. Only after starting explorer from a command prompt will it return. I've also tried executing a call to those commands in a .bat file, but I get the same problem (although the .bat file works properly when executed on its own, outside Visual Studio). I've also tried putting the relaunch part in a post-build event, but no dice. Is there any trick to getting Explorer to relaunch successfully in a pre-build event? Thanks for any input.

VS2015 C++ Multiply defined symbols only when exporting to a dll

$
0
0

Hi everyone,

I'm using Microsoft Visual Studio 2015 Community Edition (C++ code). I have a relatively simple, class template (fully generic, all methods defined inside class declaration, no type specializations) used by multiple projects.

One of my projects compiles only if that project is set to export to a static library. If I make it a dynamic library, the linker complains that the instantiation of the constructor of the aforementioned class template is multiply defined in two .obj files.

Note: the two .obj files contain the method definitions of two classes, one of which is derived from the other (i.e. base.obj and dervied.obj.)

I have tried inlining the constructor but it didn't help. Also, forcing output generates an invalid dll file.

Is this a bug? Is there a setting that I could use to get around this?

Error MSB4057

$
0
0
Severity Code Description Project File Line Suppression State
Error MSB4057 The target "ResolveTagHelperRazorGenerateInputs" does not exist in the project. SunWeb.Web C:\Program Files\dotnet\sdk\2.1.602\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets 227 

An error occurred while signing: SignTool.exe not found.

$
0
0

I recently upgraded from Visual Studio 2013 Community to the 2015 edition of Community. However, when I attempted to open one of my older projects that i created in VS 2013 Community, the error, "An error occurred while signing: SignTool.exe not found.", prevented my ability to run the project.

I faced this issue with a C# console application as well, but when i created a new project and copied the code from the original project, it worked as expected.  However, this project that I am now facing the issue with is a VB project, that has multiple forms and a substantial amount of controls, so I am unable to just copy and paste code on this occasion.

It is very important that I am able to work on this project, so any help/suggestion is welcome.

Thank you

Ian H

Transforming T4 template on build intermittently produces an exception

$
0
0

Hi all,

I'm using 

<PropertyGroup><TransformOnBuild>True</TransformOnBuild> <OverwriteReadOnlyOutputFiles>true</OverwriteReadOnlyOutputFiles><TransformOutOfDateOnly>false</TransformOutOfDateOnly></PropertyGroup>

to transform all templates in the project upon building. This works most of the time, however, sometimes it throws this:

error : An Exception was thrown while processing a directive named 'Dsl'. The transformation will not be run.  The following Exception was thrown: [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
error : System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.Modeling.Sdk.15.0, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
error : File name: 'Microsoft.VisualStudio.Modeling.Sdk.15.0, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
error :    at Microsoft.VisualStudio.Modeling.DslDefinition.DslDirectiveProcessorBase.GeneratePostInitializationCode(String directiveName, StringBuilder codeBuffer, CodeDomProvider languageProvider, IDictionary`2 requiresArguments, IDictionary`2 providesArguments) [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
error :    at Microsoft.VisualStudio.Modeling.DslDefinition.DslDirectiveProcessor.GeneratePostInitializationCode(String directiveName, StringBuilder codeBuffer, CodeDomProvider languageProvider, IDictionary`2 requiresArguments, IDictionary`2 providesArguments) [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
error :    at Microsoft.VisualStudio.TextTemplating.RequiresProvidesDirectiveProcessor.ProcessDirective(String directiveName, IDictionary`2 arguments) [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
error :    at Microsoft.VisualStudio.TextTemplating.Engine.ProcessCustomDirectives(ITextTemplatingEngineHost host, TemplateProcessingSession session, ITelemetryScope scope, IEnumerable`1 directivesToBeProcessed) [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
error :  [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
error : WRN: Assembly binding logging is turned OFF. [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
error : To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
error : Note: There is some performance penalty associated with assembly bind failure logging. [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
error : To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
error : . Line=4, Column=4 [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]

I rebuilt this project 1000 times overnight, and it threw this exception twice. It normally wouldn't be a problem, but this project will be part of a TFS build pipeline, and I wouldn't want this to cause any failures.

Considering it builds 99% of the time, I'm pretty lost on what could be the cause of this.

Viewing all 2763 articles
Browse latest View live


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