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

MSBuild.exe build solution but change the /arch

$
0
0

I have a ".sln" file that I want to be able to build, it outputs a ".dll", but instead of having to go through the Visual Studio Code Menu I was hoping to build it for "SSE2", "AVX", "AVX2" and "IA32", with 4 commands or something along the lines in a ".bat" file.

So far I was able to do this:

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" -ds Osiris.sln /t:Osiris /p:Configuration="Release" /p:Platform="x86 

And this simply builds the current ".sln" with the saved configuration, what I was hoping to do was change the "/ARCH:" function on each run an output these in this format:

"{proj name}_-_{instruction_set}.dll

Thanks very much in advance,

James

If I am approaching this the completely and totally wrong way please feel free to correct me :)))))


Builds are failing after position take over

$
0
0

I recently took over the position of an former staff member. I was instructed to use my own MS account, not that of the former colleague. This may or may not be significant but ever since yesterday morning when this change took effect, none of the builds I'm kicking off OR that my teams members are initiating on check ins are completing successfully. We're getting partial completions. Thoughts?

Exception Message: TF270015: 'MSBuild.exe' returned an unexpected exit code. Expected '0'; actual '1'. See the build logs for more details. (type UnexpectedExitCodeException) Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Built C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets for default targets.

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets (1565): TF270002: An error occurred copying files from 'e:\erp-1\87258\324\bin' to '$/integraERP/Drops/2.14.12.1/integraERP/2.14.12.1 integraERP_20200317.2'. Details: The path e:\erp-1\87258\324\bin is already mapped in workspace VersionControlDropWorkspace_fa00f803-2895-4782-bf18-19f1268718e8;b0e720ac-5939-4f34-8d84-497ae0ef6171.

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets (1565): The "CopyDirectoryTask" task failed unexpectedly. Microsoft.TeamFoundation.Build.Workflow.Activities.CopyDirectoryException: TF270002: An error occurred copying files from 'e:\erp-1\87258\324\bin' to '$/integraERP/Drops/2.14.12.1/integraERP/2.14.12.1 integraERP_20200317.2'. Details: The path e:\erp-1\87258\324\bin is already mapped in workspace VersionControlDropWorkspace_fa00f803-2895-4782-bf18-19f1268718e8;b0e720ac-5939-4f34-8d84-497ae0ef6171. ---> Microsoft.TeamFoundation.VersionControl.Client.MappingConflictException: The path e:\erp-1\87258\324\bin is already mapped in workspace VersionControlDropWorkspace_fa00f803-2895-4782-bf18-19f1268718e8;b0e720ac-5939-4f34-8d84-497ae0ef6171. at Microsoft.TeamFoundation.VersionControl.Client.InternalCache.CheckForMappingConflicts(WorkspaceInfo workspaceToCheck, WorkspaceInfo workspaceToIgnore) at Microsoft.TeamFoundation.VersionControl.Client.Client.CreateWorkspace(CreateWorkspaceParameters cwp) at Microsoft.TeamFoundation.Build.Client.BuildClientUtil.CreateWorkspace(VersionControlServer versionControl, String name, IEnumerable1 folders, String comment, IEnumerable1 wsSecurity) at Microsoft.TeamFoundation.Build.Workflow.Activities.VersionControlDropProvider.GetWorkspace(String serverPath, String localPath) at Microsoft.TeamFoundation.Build.Workflow.Activities.VersionControlDropProvider.CopyItems(String sourceDirectory, String targetDirectory, String[] items, Boolean copySource) --- End of inner exception stack trace --- at System.Activities.WorkflowApplication.Invoke(Activity activity, IDictionary2 inputs, WorkflowInstanceExtensionManager extensions, TimeSpan timeout) at System.Activities.WorkflowInvoker.Invoke(Activity workflow, IDictionary2 inputs, TimeSpan timeout, WorkflowInstanceExtensionManager extensions) at Microsoft.TeamFoundation.Build.Tasks.WorkflowTask.ExecuteInternal() at Microsoft.TeamFoundation.Build.Tasks.Task.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext()

my projects don't run

$
0
0

hi

why my project doesn't run?

I uninstalled my vs2012 and installed vs2019 but I still have this problem

even I open from main way that it saved, it doesn't work

the error is:

Severity Code Description Project File Line Suppression State
Error  Unable to create a manifest resource name for "..\..\..\..\..\Desktop\school\1 paygah dade\podman 3\form\calculator\calculator.resx". Could not find a part of the path 'C:\Users\Dell\Desktop\1 paygah dade\Desktop\school\1 paygah dade\podman 3\form\calculator\calculator.cs'. calculator   

Lot of Unnecessary Visual Studio Rebuilds - Tracking Log problem?

$
0
0

Hi - I'm getting an awful lot of unnecessary Visual Studio (2017) rebuilds.  Mine is a big Visual C++ project and all these builds are hitting my productivity badly so all help much appreciated.

I can't detect a pattern to the problem.  My perception is that sometimes it rebuilds practically every file when I've just changed one .cpp file.  Sometimes after a full build, if I hit build again, it will rebuild loads more files.  But sometimes it doesn't rebuild anything because it recognises that everything is up-to-date.

When this happened yet again just now (loads of files being rebuilt for no reason that I could see), I stopped the build and clicked on Tools -> Options. I chose Projects and Solutions -> Build and Run and selected Diagnostic in “MSbuild project build log file verbosity”.  I then restarted the build, waited a while, and checked the log file.  It had more than 10 pages filled with lines like this:

                     <source file>.cpp will be compiled because it was not found in the tracking log. (TaskId:28)


Anyone got any suggestions what the problem could be?


Simon

Can I add a border to a textblock in C#

$
0
0

I want to add border to a textblock in my C# project but I can not find a property for it, in properties list !

The textblock have a border property?


Karim Vaziri Regards,

MSBuild API - Unknown build error with XAML files.

$
0
0
Hi,

I am making use of the Microsoft.Build.Locator nuget package (currently on version 1.2.6) and I have the latest version of Visual Studio 2019 installed.

With this, I am trying to build a couple of C# Class Library projects, where some of them contains custom WPF user controls.

So far a lot of them have built fine, but as soon as it hits the first project containing XAML files, I receive the following error:

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(268,9): error MC1000: Unknown build error, 'Object reference not set to an instance of an object.'

I have tried to search for solutions from other people, but couldn't find anything that made sense for my particular case yet.

We have used the Microsoft.Build assemblies in the past, before the Microsoft.Build.Locator existed, and it has worked perfectly fine up until now, including projects with XAML files. So now we would just like to upgrade to the latest way of using the MSBuild API, but we are stuck on this problem.

Please let me know if I can supply more information and also if this post should be done somewhere else?

Thank you very much!

Stevie de Manielle

MSBuild Nuget Restore without Cache

$
0
0

I have a .Net solution which has many projects. One of the projects in the solution has a Package Reference element as shown below.

<PackageReference Include="MyPackage" Version="*" GeneratePathProperty="true" />

I have msbuild command as follows

msbuild MyCustom.sln -verbosity:m  -t:restore,clean,build /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile /p:WarningLevel=0 /p:DebugSymbols=false 

MyPackage nuget package is uploaded to a Nuget source (JFrog Artifactory Nuget repo). In this, I have 5 versions of a package uploaded there. Just a day ago, I uploaded version 6 with some changes. 

I have 2 different Jenkins jobs running on the same server which use MyPackage. One job was created a little earlier and the other job was created a day ago. Even though I have uploaded version 6, the first job created earlier is using version 5, even if we specify "restore" target in the msbuild command. 

I understand that Package Reference installs the package to %USERPROFILE%\.nuget\packages\MyPackage folder. 

I referred the following link.

https://docs.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders

As per this, there are various levels of caching which can be cleared. But for me, only nuget locals global-packages -clear is working. But this is an issue for me because it the PackageReference path is a common path for other jobs which might break, as this command deletes the whole packages folder. Also, it is possible that some other project / job might still need to use version 5. Other cache clearing options from the above link are not working for me. I am confused.

I also tried other variations on the msbuild command like below.

msbuild MyCustom.sln -verbosity:m  -t:restore,clean,build /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile /p:WarningLevel=0 /p:DebugSymbols=false /p:RestoreForce="true"

msbuild MyCustom.sln -verbosity:m  -t:clean,build /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile /p:WarningLevel=0 /p:DebugSymbols=false /restore

msbuild MyCustom.sln -verbosity:m  -t:clean,build /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile /p:WarningLevel=0 /p:DebugSymbols=false /restore /p:RestoreForce="true"

But it doesn't seem to be working.

Note: I don't want to delete existing packages or even existing versions of a package. I just want to make sure the latest version is downloaded / installed into the packages location when restore is called and when version in PackageReference element is specified as *.

Can anyone please help me?


Ven

in .targets file breaks in inheriting projects.

$
0
0

This is my .targets file, it overwrites any AdditionalLibraryDirectories that are specified in other projects:

<Project>
    <PropertyGroup>
        <ROOT>C:\Repo\</ROOT> <!--OY DEV: UPDATE ME!-->
    </PropertyGroup>
    <PropertyGroup Label="Globals">
        <IncludePath>$(ROOT);$(IncludePath)</IncludePath>
    </PropertyGroup>
    <ItemDefinitionGroup>
        <Link>
            <AdditionalLibraryDirectories>$(ROOT)\lib;$(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
        </Link>
    </ItemDefinitionGroup>
</Project>



How to step into a local Nuget package that includes .dll/.pdb and source

$
0
0

We currently have several projects using assembly references (in separate solutions) with relative hint paths. These are all built on dev workstations and shared with other developers through various means. We are attempting to refactor these so that they are built with MSBuild on our CI server, pulling in dependencies from a local NuGet feed, and then packaging and pushing to that local NuGet feed. All of this is working.

During this refactor, questions have come up with how local development and debugging will work now that the projects refer to each other with PackageReference. We do not want the developers to push to our NuGet feed or a NuGet symbol server during development. The goal is that when debugging one project, we want to (still) be able to step-into a method call in a dependent package. We understand that the dependent package will need a symbol file in order to do this and potentially source files as well.

We have tried packaging the dependent package with the newer/recommended .snupkg format, while specifying both IncludeSymbols and IncludeSources options. The source never gets packaged within the .snupkg file, likely due to issue #8589 in the GitHub NuGet project. And when debugging, VS does not "step into" the package's source.

We have tried with the older (and still default) .symbol.nupkg format. In this case, the source does get packaged with the .symbol.nupkg format (it is in a src/ directory when you unzip that file). However, VS still does not "step into" the package's source when using the debugger.

We build/package this dependent library from its VS solution, and then add that Nuget reference to a local directory. That local directory is setup as a symbol server in VS Debugger options.

Weirdly enough, we can use "Go to declaration" on the method which pops up source "from metadata". However, "step into" does not step into the source.

These are all full framework, .Net 4.5.2 projects files. We are not using the "SDK style" project file format.

I've read up as much as I can find online, but cannot find guidance for what we are trying to do. Perhaps that means what we are trying to do is simply not supported by VS, but it seems like it should be.

Does anyone have a suggestion to resolve the debugging issue we are running into?

C# Checking app integrity before compiling

$
0
0

Hi. 

I am trying to implement a security solution into my app.

I've created a remote database containing hash codes of each project file.

When I send my app to someone else and he would try to compile it again I want to (before compiling):

  • request internet access
  • create hash codes of the project files and compare them to the ones in the remote database
  • if everything checks (no changes in project), the code would compile, otherwise it would not compile

I'm really not sure how to do those things before compilation.


Visual Studio deletes a .pch file and cutom build steps

$
0
0

I try to use a shared .pch file, which is compiled in one project and used in others.

However the .pch file is deleted if a .pdb filename of the PCH project differs from .pdb filenames of the other projects.

This page doesn't answer the question: https://devblogs.microsoft.com/cppblog/shared-pch-usage-sample-in-visual-studio/

I don't want to use a same name for all PDBs.

Questions:

1) Why the .pch file is deleted at the start of other projects compilation, which leads to a C1083 error (.pch not found), if PDB names are not equal, not like in that page?

2) I copy pch.pdb and pch.idb files using COPY command, is there a RENAME comand or something, if the copied pch.pdb should be named just like a dependent project's PDB? And where can I find a complete list of Custom Build Step command?

3) I don't understand the purpose of "Additional dependencies" and "Outputs" in Custom Build Step. Can I enter the .pch filename into the dependency list, so it won't be deleted? Does the output list need to contain the dependent project's PDB name, or the pch.pdb, or both?





CFrameWndex::OnSetText change from VS 2008 to VS 2013?

$
0
0
I am upgrading from VS 2008 to VS 2013. For a dependency on another tool we are using, I can't go to VS 2019.

I have this code which works in VS 2008, but is giving errors in 2013:

/*-----------------------------------------------------------------------
 * RtStatusbar::OnSetText
 *    Prevent blank status bars (NOTE: Only called if Pane 0 is updated)
 *----------------------------------------------------------------------*/
LRESULT RtStatusbar::
      OnSetText(WPARAM wParam, LPARAM lParam)
{
   // Do not RtTraceEntry high velocity methods

   // If blank use the last permanent
   if (lParam && !(*((TCHAR *)lParam)) && !mOkBlank)
      return CStatusBar::OnSetText(wParam,(LPARAM)(LPCTSTR)mPaneText[0]);

   // Ok, pass it on as is
   return CStatusBar::OnSetText(wParam,lParam);
}


I get these errors in VS 2013:

Error 1186 error C2660: 'CStatusBar::OnSetText' : function does not take 2 arguments D:\RTWIN\BSF\Source\RtStatBr.cpp 450 1 PswrCtls

Error 1187 error C2660: 'CStatusBar::OnSetText' : function does not take 2 arguments D:\RTWIN\BSF\Source\RtStatBr.cpp 453 1 PswrCtls

If I look a the VS 2015 docuementation (can't find the 2013 documentation), OnSetText is a member function of CFrameWndex and it has 2 parameters: https://docs.microsoft.com/en-us/cpp/mfc/reference/cframewndex-class?view=vs-2015#onsettext

But if I search for OnSetText in VS 2013 files, it shows only 1 parameter:

C:\Program Files (x86)>findstr /s OnSetText *.h
Microsoft SDKs\Windows\v7.1A\Include\WindowsX.h:/* void Cls_OnSetText(HWND hwnd, LPCTSTR lpszText) */
Microsoft Visual Studio 12.0\VC\atlmfc\include\afxctl.h:        afx_msg int OnSetText(LPCTSTR lpszText);
Microsoft Visual Studio 12.0\VC\atlmfc\include\afxdockablepane.h:       afx_msg int OnSetText(LPCTSTR lpszText);
Microsoft Visual Studio 12.0\VC\atlmfc\include\afxext.h:        afx_msg int OnSetText(LPCTSTR lpszText);
Microsoft Visual Studio 12.0\VC\atlmfc\include\afxframeimpl.h:  void OnSetText(LPCTSTR lpszText);
Microsoft Visual Studio 12.0\VC\atlmfc\include\afxframewndex.h: afx_msg int OnSetText(LPCTSTR lpszText);
Microsoft Visual Studio 12.0\VC\atlmfc\include\afxmaskededit.h: afx_msg int OnSetText(LPCTSTR lpszText);
Microsoft Visual Studio 12.0\VC\atlmfc\include\afxmdichildwndex.h:      afx_msg int OnSetText(LPCTSTR lpszText);
Microsoft Visual Studio 12.0\VC\atlmfc\include\afxmdiframewndex.h:      afx_msg int OnSetText(LPCTSTR lpszText);
Microsoft Visual Studio 12.0\VC\atlmfc\include\afxmsg_.h:       (static_cast< int (AFX_MSG_CALL CWnd::*)(LPCTSTR) > ( &ThisClass :: OnSetText)) },
Microsoft Visual Studio 12.0\VC\atlmfc\include\afxstatusbar.h:  afx_msg int OnSetText(LPCTSTR lpszText);
Microsoft Visual Studio 12.0\VC\atlmfc\include\afxtaskspane.h:  afx_msg int OnSetText(LPCTSTR lpszText);
Microsoft Visual Studio 12.0\VC\atlmfc\include\afxvslistbox.h:  afx_msg int OnSetText(LPCTSTR lpszText);
Windows Kits\8.1\Include\shared\windowsx.h:/* void Cls_OnSetText(HWND hwnd, LPCTSTR lpszText) */

C:\Program Files (x86)>

But if I search for it in VS 2008, it shows the 2 parameters:

C:\VSNET2008>findstr /s OnSetText *.h
VC\atlmfc\include\afxctl.h:     afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
VC\atlmfc\include\afxdockablepane.h:    afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
VC\atlmfc\include\afxext.h:     afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
VC\atlmfc\include\afxframeimpl.h:       void OnSetText(LPCTSTR lpszText);
VC\atlmfc\include\afxframewndex.h:      afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
VC\atlmfc\include\afxmaskededit.h:      afx_msg LRESULT OnSetText(WPARAM, LPARAM);
VC\atlmfc\include\afxmdichildwndex.h:   afx_msg LRESULT OnSetText(WPARAM,LPARAM);
VC\atlmfc\include\afxmdiframewndex.h:   afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
VC\atlmfc\include\afxstatusbar.h:       afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
VC\atlmfc\include\afxtaskspane.h:       afx_msg LRESULT OnSetText(WPARAM, LPARAM);
VC\atlmfc\include\afxvslistbox.h:       afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
VC\ce\atlmfc\include\afxctl.h:  afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
VC\ce\atlmfc\include\afxext.h:  afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);

C:\VSNET2008>

So, was the definition changed from VS 2008 to VS 2013,and then changed back after VS 2013?



ERRO MSB4018 na hora de compilar no Visual Studio Community

$
0
0
Olá estou com problema na hora de compilar um programa da esse erro ai. Já tentei reparar o visual desisntalei por varias vezes e reinstalei e não funcionou, tudo começou quando fui instalar uma extensão do python no visual até isso funcionava tudo normalmente.

Cannot run a CUDA project getting this error any suggestions ?

$
0
0

Error MSB4019 The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 9.0.props" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\\BuildCustomizations\CUDA 9.0.props" is correct, and that the file exists on disk. vectorAdd C:\Users\Ivan\Documents\Visual Studio 2019\Templates\ProjectTemplates\Visual C++ Project\original\vectorAdd\vectorAdd_vs2012.vcxproj 44 

MSB6003_The specified task executable "CL.exe" could not be run. The requested operation cannot be performed on a file with a user-mapped section open.

$
0
0

Hello,

Getting the following error when i am trying to compile the code.

MSB6003The specified task executable "CL.exe" could not be run. The requested operation cannot be performed on a file with a user-mapped section open.

Regards,

Spandana K.


Visual Studio deletes a shared .pch file, and questions about custom build steps

$
0
0

I try to use a shared .pch file, which is compiled in one project and used in others.

However the .pch file is deleted if a .pdb filename of the PCH project differs from .pdb filenames of the other projects.

This page doesn't answer the question: https://devblogs.microsoft.com/cppblog/shared-pch-usage-sample-in-visual-studio/

I don't want to use a same name for all PDBs.

Questions:

1) Why the .pch file is deleted at the start of other projects compilation, which leads to a C1083 error (.pch not found), if PDB names are not equal, not like in that page?

2) I copy pch.pdb and pch.idb files using COPY command, is there a RENAME comand or something, if the copied pch.pdb should be named just like a dependent project's PDB? And where can I find a complete list of Custom Build Step command?

3) I don't understand the purpose of "Additional dependencies" and "Outputs" in Custom Build Step. Can I enter the .pch filename into the dependency list, so it won't be deleted? Does the output list need to contain the dependent project's PDB name, or the pch.pdb, or both?






While migrating compiler from visual studio 2010 to visual studio 2019 , Getting error in type_traits

$
0
0

While migrating compiler from visual studio 2010 to visual studio 2019 , Getting error in type_traits :

type_traits(206): error C2947: expecting '>' to terminate template-argument-list, found '<'

Code is working fine with visual studio 2010 , but when I switched compiler to vs 2019 . This error as well as similar more errors started.

Please help me in fixing this migration issue.

Msbuild is not considering Optimize flag Off in release mode

$
0
0

Hi,

I am building my code with a specific version of MsBuild i.e. >C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild Build.proj /t:BuildCode. Even though I have switched Off Optimize Code flag , build it is still compiling my DLL with optimizations, this is happening only with Release mode not in Debug mode.

If I build same with Visual Studio 2015 then it is considering the optimize Code flag and I am not seeing any compiler optimization upon de-compiling dll through ILSpy.

Reason I want to switch Off Optimize Code option is my unit test cases starts failing as soon this flag is enabled, I don't know why but that is the behavior which I have noticed.

Thanks,
Neeraj

Copy Task for Empty Sub directories, Copy Count and Files List

$
0
0

Does anyone know how I can achieve the following from MSBuild Copy task? (Not XCOPY or ROBOCOPY)

1. Copy empty sub folders recursively while copying? 

2. How can I get the number of files / folders copied? 

3. How can I get the verbose output (status) which include the list of files / folders being copied?

I believe we can achieve most (or all) of the above with XCOPY or ROBOCOPY. But I have been asked to use Copy Task. 

Can anyone please help?


Ven

Cannot get rid Newtonsoft.Json.dll

$
0
0
I have a console app (.net core 3.1) using generic host.
Even if none of the projects reference Newtonsoft at all (and NUGET package is not added), it is included in the binaries every time the projects are built.
How to get rid of it? (it is quite big actually)
Viewing all 2763 articles
Browse latest View live


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